Thank you for your interest in contributing to Rust! There are many ways to contribute
and we appreciate all of them.
+The best way to get started is by asking for help in the [#new
+members](https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members)
+Zulip stream. We have lots of docs below of how to get started on your own, but
+the Zulip stream is the best place to *ask* for help.
+
Documentation for contributing to Rust is located in the [Guide to Rustc Development](https://rustc-dev-guide.rust-lang.org/),
commonly known as the [rustc-dev-guide]. Despite the name, this guide documents
-not just how to develop rustc (the Rust compiler), but also how to contribute to any part
-of the Rust project.
-
-To get started with contributing, please read the [Contributing to Rust] chapter of the guide.
-That chapter explains how to get your development environment set up and how to get help.
+not just how to develop rustc (the Rust compiler), but also how to contribute to the standard library and rustdoc.
## About the [rustc-dev-guide]
[[package]]
name = "curl"
-version = "0.4.40"
+version = "0.4.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "877cc2f9b8367e32b6dabb9d581557e651cb3aa693a37f8679091bbf42687d5d"
+checksum = "1bc6d233563261f8db6ffb83bbaad5a73837a6e6b28868e926337ebbdece0be3"
dependencies = [
"curl-sys",
"libc",
[[package]]
name = "curl-sys"
-version = "0.4.50+curl-7.79.1"
+version = "0.4.51+curl-7.80.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4856b76919dd599f31236bb18db5f5bd36e2ce131e64f857ca5c259665b76171"
+checksum = "d130987e6a6a34fe0889e1083022fa48cd90e6709a84be3fb8dd95801de5af20"
dependencies = [
"cc",
"libc",
**Note: this README is for _users_ rather than _contributors_.
If you wish to _contribute_ to the compiler, you should read the
-[Getting Started][gettingstarted] section of the rustc-dev-guide instead.**
+[Getting Started][gettingstarted] section of the rustc-dev-guide instead.
+You can ask for help in the [#new members Zulip stream][new-members].**
+
+[new-members]: https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members
## Quick Start
// alloc() will trigger a grow().
ptr: Cell::new(ptr::null_mut()),
end: Cell::new(ptr::null_mut()),
- chunks: RefCell::new(vec![]),
+ chunks: Default::default(),
_own: PhantomData,
}
}
unsafe impl<T: Send> Send for TypedArena<T> {}
+/// An arena that can hold objects of multiple different types that impl `Copy`
+/// and/or satisfy `!mem::needs_drop`.
pub struct DroplessArena {
/// A pointer to the start of the free space.
start: Cell<*mut u8>,
/// A pointer to the end of free space.
///
- /// The allocation proceeds from the end of the chunk towards the start.
+ /// The allocation proceeds downwards from the end of the chunk towards the
+ /// start. (This is slightly simpler and faster than allocating upwards,
+ /// see <https://fitzgeraldnick.com/2019/11/01/always-bump-downwards.html>.)
/// When this pointer crosses the start pointer, a new chunk is allocated.
end: Cell<*mut u8>,
}
}
+// Declare an `Arena` containing one dropless arena and many typed arenas (the
+// types of the typed arenas are specified by the arguments). The dropless
+// arena will be used for any types that impl `Copy`, and also for any of the
+// specified types that satisfy `!mem::needs_drop`.
#[rustc_macro_transparency = "semitransparent"]
-pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) {
+pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
#[derive(Default)]
- pub struct Arena<$tcx> {
+ pub struct Arena<'tcx> {
pub dropless: $crate::DroplessArena,
$($name: $crate::TypedArena<$ty>,)*
}
) -> &'a mut [Self];
}
+ // Any type that impls `Copy` can be arena-allocated in the `DroplessArena`.
impl<'tcx, T: Copy> ArenaAllocatable<'tcx, ()> for T {
#[inline]
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
) -> &'a mut [Self] {
arena.dropless.alloc_from_iter(iter)
}
-
}
$(
- impl<$tcx> ArenaAllocatable<$tcx, $ty> for $ty {
+ impl<'tcx> ArenaAllocatable<'tcx, $ty> for $ty {
#[inline]
- fn allocate_on<'a>(self, arena: &'a Arena<$tcx>) -> &'a mut Self {
+ fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
if !::std::mem::needs_drop::<Self>() {
arena.dropless.alloc(self)
} else {
#[inline]
fn allocate_from_iter<'a>(
- arena: &'a Arena<$tcx>,
+ arena: &'a Arena<'tcx>,
iter: impl ::std::iter::IntoIterator<Item = Self>,
) -> &'a mut [Self] {
if !::std::mem::needs_drop::<Self>() {
value.allocate_on(self)
}
+ // Any type that impls `Copy` can have slices be arena-allocated in the `DroplessArena`.
#[inline]
pub fn alloc_slice<T: ::std::marker::Copy>(&self, value: &[T]) -> &mut [T] {
if value.is_empty() {
use rustc_span::hygiene::ExpnId;
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
use rustc_span::symbol::{sym, Ident, Symbol};
-use rustc_span::{hygiene::ForLoopLoc, DUMMY_SP};
+use rustc_span::DUMMY_SP;
impl<'hir> LoweringContext<'_, 'hir> {
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
/// Desugar `ExprForLoop` from: `[opt_ident]: for <pat> in <head> <body>` into:
/// ```rust
/// {
- /// let result = match ::std::iter::IntoIterator::into_iter(<head>) {
+ /// let result = match IntoIterator::into_iter(<head>) {
/// mut iter => {
/// [opt_ident]: loop {
- /// let mut __next;
- /// match ::std::iter::Iterator::next(&mut iter) {
- /// ::std::option::Option::Some(val) => __next = val,
- /// ::std::option::Option::None => break
+ /// match Iterator::next(&mut iter) {
+ /// None => break,
+ /// Some(<pat>) => <body>,
/// };
- /// let <pat> = __next;
- /// StmtKind::Expr(<body>);
/// }
/// }
/// };
body: &Block,
opt_label: Option<Label>,
) -> hir::Expr<'hir> {
- // expand <head>
let head = self.lower_expr_mut(head);
- let desugared_span =
- self.mark_span_with_reason(DesugaringKind::ForLoop(ForLoopLoc::Head), head.span, None);
- let e_span = self.lower_span(e.span);
-
- let iter = Ident::with_dummy_span(sym::iter);
-
- let next_ident = Ident::with_dummy_span(sym::__next);
- let (next_pat, next_pat_hid) = self.pat_ident_binding_mode(
- desugared_span,
- next_ident,
- hir::BindingAnnotation::Mutable,
- );
-
- // `::std::option::Option::Some(val) => __next = val`
- let pat_arm = {
- let val_ident = Ident::with_dummy_span(sym::val);
- let pat_span = self.lower_span(pat.span);
- let (val_pat, val_pat_hid) = self.pat_ident(pat_span, val_ident);
- let val_expr = self.expr_ident(pat_span, val_ident, val_pat_hid);
- let next_expr = self.expr_ident(pat_span, next_ident, next_pat_hid);
- let assign = self.arena.alloc(self.expr(
- pat_span,
- hir::ExprKind::Assign(next_expr, val_expr, self.lower_span(pat_span)),
- ThinVec::new(),
- ));
- let some_pat = self.pat_some(pat_span, val_pat);
- self.arm(some_pat, assign)
- };
+ let pat = self.lower_pat(pat);
+ let for_span =
+ self.mark_span_with_reason(DesugaringKind::ForLoop, self.lower_span(e.span), None);
+ let head_span = self.mark_span_with_reason(DesugaringKind::ForLoop, head.span, None);
+ let pat_span = self.mark_span_with_reason(DesugaringKind::ForLoop, pat.span, None);
- // `::std::option::Option::None => break`
- let break_arm = {
+ // `None => break`
+ let none_arm = {
let break_expr =
- self.with_loop_scope(e.id, |this| this.expr_break_alloc(e_span, ThinVec::new()));
- let pat = self.pat_none(e_span);
+ self.with_loop_scope(e.id, |this| this.expr_break_alloc(for_span, ThinVec::new()));
+ let pat = self.pat_none(for_span);
self.arm(pat, break_expr)
};
+ // Some(<pat>) => <body>,
+ let some_arm = {
+ let some_pat = self.pat_some(pat_span, pat);
+ let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
+ let body_expr = self.arena.alloc(self.expr_block(body_block, ThinVec::new()));
+ self.arm(some_pat, body_expr)
+ };
+
// `mut iter`
+ let iter = Ident::with_dummy_span(sym::iter);
let (iter_pat, iter_pat_nid) =
- self.pat_ident_binding_mode(desugared_span, iter, hir::BindingAnnotation::Mutable);
+ self.pat_ident_binding_mode(head_span, iter, hir::BindingAnnotation::Mutable);
- // `match ::std::iter::Iterator::next(&mut iter) { ... }`
+ // `match Iterator::next(&mut iter) { ... }`
let match_expr = {
- let iter = self.expr_ident(desugared_span, iter, iter_pat_nid);
- let ref_mut_iter = self.expr_mut_addr_of(desugared_span, iter);
+ let iter = self.expr_ident(head_span, iter, iter_pat_nid);
+ let ref_mut_iter = self.expr_mut_addr_of(head_span, iter);
let next_expr = self.expr_call_lang_item_fn(
- desugared_span,
+ head_span,
hir::LangItem::IteratorNext,
arena_vec![self; ref_mut_iter],
);
- let arms = arena_vec![self; pat_arm, break_arm];
+ let arms = arena_vec![self; none_arm, some_arm];
- self.expr_match(desugared_span, next_expr, arms, hir::MatchSource::ForLoopDesugar)
+ self.expr_match(head_span, next_expr, arms, hir::MatchSource::ForLoopDesugar)
};
- let match_stmt = self.stmt_expr(desugared_span, match_expr);
-
- let next_expr = self.expr_ident(desugared_span, next_ident, next_pat_hid);
-
- // `let mut __next`
- let next_let = self.stmt_let_pat(
- None,
- desugared_span,
- None,
- next_pat,
- hir::LocalSource::ForLoopDesugar,
- );
+ let match_stmt = self.stmt_expr(for_span, match_expr);
- // `let <pat> = __next`
- let pat = self.lower_pat(pat);
- let pat_let = self.stmt_let_pat(
- None,
- desugared_span,
- Some(next_expr),
- pat,
- hir::LocalSource::ForLoopDesugar,
- );
-
- let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
- let body_expr = self.expr_block(body_block, ThinVec::new());
- let body_stmt = self.stmt_expr(body_block.span, body_expr);
-
- let loop_block = self.block_all(
- e_span,
- arena_vec![self; next_let, match_stmt, pat_let, body_stmt],
- None,
- );
+ let loop_block = self.block_all(for_span, arena_vec![self; match_stmt], None);
// `[opt_ident]: loop { ... }`
let kind = hir::ExprKind::Loop(
loop_block,
self.lower_label(opt_label),
hir::LoopSource::ForLoop,
- self.lower_span(e_span.with_hi(head.span.hi())),
+ self.lower_span(for_span.with_hi(head.span.hi())),
);
- let loop_expr = self.arena.alloc(hir::Expr {
- hir_id: self.lower_node_id(e.id),
- kind,
- span: self.lower_span(e.span),
- });
+ let loop_expr =
+ self.arena.alloc(hir::Expr { hir_id: self.lower_node_id(e.id), kind, span: for_span });
// `mut iter => { ... }`
let iter_arm = self.arm(iter_pat, loop_expr);
- let into_iter_span = self.mark_span_with_reason(
- DesugaringKind::ForLoop(ForLoopLoc::IntoIter),
- head.span,
- None,
- );
-
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
let into_iter_expr = {
self.expr_call_lang_item_fn(
- into_iter_span,
+ head_span,
hir::LangItem::IntoIterIntoIter,
arena_vec![self; head],
)
};
- // #82462: to correctly diagnose borrow errors, the block that contains
- // the iter expr needs to have a span that covers the loop body.
- let desugared_full_span =
- self.mark_span_with_reason(DesugaringKind::ForLoop(ForLoopLoc::Head), e_span, None);
-
let match_expr = self.arena.alloc(self.expr_match(
- desugared_full_span,
+ for_span,
into_iter_expr,
arena_vec![self; iter_arm],
hir::MatchSource::ForLoopDesugar,
// surrounding scope of the `match` since the `match` is not a terminating scope.
//
// Also, add the attributes to the outer returned expr node.
- self.expr_drop_temps_mut(desugared_full_span, match_expr, attrs.into())
+ self.expr_drop_temps_mut(for_span, match_expr, attrs.into())
}
/// Desugar `ExprKind::Try` from: `<expr>?` into:
mod pat;
mod path;
-rustc_hir::arena_types!(rustc_arena::declare_arena, 'tcx);
+rustc_hir::arena_types!(rustc_arena::declare_arena);
struct LoweringContext<'a, 'hir: 'a> {
/// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
pure_wrt_drop: false,
bounds: hir_bounds,
span: self.lower_span(span),
- kind: hir::GenericParamKind::Type {
- default: None,
- synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
- },
+ kind: hir::GenericParamKind::Type { default: None, synthetic: true },
});
hir::TyKind::Path(hir::QPath::Resolved(
default: default.as_ref().map(|x| {
self.lower_ty(x, ImplTraitContext::Disallowed(ImplTraitPosition::Other))
}),
- synthetic: param
- .attrs
- .iter()
- .filter(|attr| attr.has_name(sym::rustc_synthetic))
- .map(|_| hir::SyntheticTyParamKind::FromAttr)
- .next(),
+ synthetic: false,
};
(hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
gate_all!(const_trait_impl, "const trait impls are experimental");
gate_all!(half_open_range_patterns, "half-open range patterns are unstable");
gate_all!(inline_const, "inline-const is experimental");
+ gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
gate_all!(
const_generics_defaults,
"default values for const generic parameters are experimental"
use rustc_middle::ty::adjustment::PointerCast;
use rustc_middle::ty::{self, RegionVid, TyCtxt};
use rustc_span::symbol::Symbol;
-use rustc_span::Span;
+use rustc_span::{sym, DesugaringKind, Span};
use crate::region_infer::BlameConstraint;
use crate::{
should_note_order,
} => {
let local_decl = &body.local_decls[dropped_local];
- let (dtor_desc, type_desc) = match local_decl.ty.kind() {
+ let mut ty = local_decl.ty;
+ if local_decl.source_info.span.desugaring_kind() == Some(DesugaringKind::ForLoop) {
+ if let ty::Adt(adt, substs) = local_decl.ty.kind() {
+ if tcx.is_diagnostic_item(sym::Option, adt.did) {
+ // in for loop desugaring, only look at the `Some(..)` inner type
+ ty = substs.type_at(0);
+ }
+ }
+ }
+ let (dtor_desc, type_desc) = match ty.kind() {
// If type is an ADT that implements Drop, then
// simplify output by reporting just the ADT name.
ty::Adt(adt, _substs) if adt.has_dtor(tcx) && !adt.is_box() => {
use rustc_middle::ty::print::Print;
use rustc_middle::ty::{self, DefIdTree, Instance, Ty, TyCtxt};
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
-use rustc_span::{
- hygiene::{DesugaringKind, ForLoopLoc},
- symbol::sym,
- Span,
-};
+use rustc_span::{hygiene::DesugaringKind, symbol::sym, Span};
use rustc_target::abi::VariantIdx;
use super::borrow_set::BorrowData;
let kind = kind.unwrap_or_else(|| {
// This isn't a 'special' use of `self`
debug!("move_spans: method_did={:?}, fn_call_span={:?}", method_did, fn_call_span);
- let implicit_into_iter = matches!(
- fn_call_span.desugaring_kind(),
- Some(DesugaringKind::ForLoop(ForLoopLoc::IntoIter))
- );
+ let implicit_into_iter = Some(method_did) == tcx.lang_items().into_iter_fn()
+ && fn_call_span.desugaring_kind() == Some(DesugaringKind::ForLoop);
let parent_self_ty = parent
.filter(|did| tcx.def_kind(*did) == rustc_hir::def::DefKind::Impl)
.and_then(|did| match tcx.type_of(did).kind() {
},
))) => {
// check if the RHS is from desugaring
- let locations = self.body.find_assignments(local);
- let opt_assignment_rhs_span = locations
- .first()
- .map(|&location| self.body.source_info(location).span);
- let opt_desugaring_kind =
- opt_assignment_rhs_span.and_then(|span| span.desugaring_kind());
- match opt_desugaring_kind {
+ let opt_assignment_rhs_span =
+ self.body.find_assignments(local).first().map(|&location| {
+ let stmt = &self.body[location.block].statements
+ [location.statement_index];
+ match stmt.kind {
+ mir::StatementKind::Assign(box (
+ _,
+ mir::Rvalue::Use(mir::Operand::Copy(place)),
+ )) => {
+ self.body.local_decls[place.local].source_info.span
+ }
+ _ => self.body.source_info(location).span,
+ }
+ });
+ match opt_assignment_rhs_span.and_then(|s| s.desugaring_kind()) {
// on for loops, RHS points to the iterator part
- Some(DesugaringKind::ForLoop(_)) => {
+ Some(DesugaringKind::ForLoop) => {
self.suggest_similar_mut_method_for_for_loop(&mut err);
Some((
false,
use rustc_session::config::OptLevel;
use rustc_session::Session;
use rustc_target::spec::abi::Abi;
-use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType};
+use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
use crate::attributes;
use crate::llvm::AttributePlace::Function;
}
}
+fn set_stackprotector(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
+ let sspattr = match cx.sess().stack_protector() {
+ StackProtector::None => return,
+ StackProtector::All => Attribute::StackProtectReq,
+ StackProtector::Strong => Attribute::StackProtectStrong,
+ StackProtector::Basic => Attribute::StackProtect,
+ };
+
+ sspattr.apply_llfn(Function, llfn)
+}
+
pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
let target_cpu = SmallCStr::new(llvm_util::target_cpu(cx.tcx.sess));
llvm::AddFunctionAttrStringValue(
set_frame_pointer_type(cx, llfn);
set_instrument_function(cx, llfn);
set_probestack(cx, llfn);
+ set_stackprotector(cx, llfn);
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
Attribute::Cold.apply_llfn(Function, llfn);
}
println!();
}
+ PrintRequest::StackProtectorStrategies => {
+ println!(
+ r#"Available stack protector strategies:
+ all
+ Generate stack canaries in all functions.
+
+ strong
+ Generate stack canaries in a function if it either:
+ - has a local variable of `[T; N]` type, regardless of `T` and `N`
+ - takes the address of a local variable.
+
+ (Note that a local variable being borrowed is not equivalent to its
+ address being taken: e.g. some borrows may be removed by optimization,
+ while by-value argument passing may be implemented with reference to a
+ local stack variable in the ABI.)
+
+ basic
+ Generate stack canaries in functions with:
+ - local variables of `[T; N]` type, where `T` is byte-sized and `N` > 8.
+
+ none
+ Do not generate stack canaries.
+"#
+ );
+ }
req => llvm_util::print(req, sess),
}
}
InaccessibleMemOnly = 27,
SanitizeHWAddress = 28,
WillReturn = 29,
+ StackProtectReq = 30,
+ StackProtectStrong = 31,
+ StackProtect = 32,
}
/// LLVMIntPredicate
sym::simd_insert => {
let index = u64::from(self.read_scalar(&args[1])?.to_u32()?);
let elem = &args[2];
- let input = &args[0];
- let (len, e_ty) = input.layout.ty.simd_size_and_type(*self.tcx);
+ let (input, input_len) = self.operand_to_simd(&args[0])?;
+ let (dest, dest_len) = self.place_to_simd(dest)?;
+ assert_eq!(input_len, dest_len, "Return vector length must match input length");
assert!(
- index < len,
- "Index `{}` must be in bounds of vector type `{}`: `[0, {})`",
+ index < dest_len,
+ "Index `{}` must be in bounds of vector with length {}`",
index,
- e_ty,
- len
- );
- assert_eq!(
- input.layout, dest.layout,
- "Return type `{}` must match vector type `{}`",
- dest.layout.ty, input.layout.ty
- );
- assert_eq!(
- elem.layout.ty, e_ty,
- "Scalar element type `{}` must match vector element type `{}`",
- elem.layout.ty, e_ty
+ dest_len
);
- for i in 0..len {
- let place = self.place_index(dest, i)?;
- let value = if i == index { *elem } else { self.operand_index(input, i)? };
- self.copy_op(&value, &place)?;
+ for i in 0..dest_len {
+ let place = self.mplace_index(&dest, i)?;
+ let value =
+ if i == index { *elem } else { self.mplace_index(&input, i)?.into() };
+ self.copy_op(&value, &place.into())?;
}
}
sym::simd_extract => {
let index = u64::from(self.read_scalar(&args[1])?.to_u32()?);
- let (len, e_ty) = args[0].layout.ty.simd_size_and_type(*self.tcx);
+ let (input, input_len) = self.operand_to_simd(&args[0])?;
assert!(
- index < len,
- "index `{}` is out-of-bounds of vector type `{}` with length `{}`",
+ index < input_len,
+ "index `{}` must be in bounds of vector with length `{}`",
index,
- e_ty,
- len
- );
- assert_eq!(
- e_ty, dest.layout.ty,
- "Return type `{}` must match vector element type `{}`",
- dest.layout.ty, e_ty
+ input_len
);
- self.copy_op(&self.operand_index(&args[0], index)?, dest)?;
+ self.copy_op(&self.mplace_index(&input, index)?.into(), dest)?;
}
sym::likely | sym::unlikely | sym::black_box => {
// These just return their argument
})
}
+ /// Converts a repr(simd) operand into an operand where `place_index` accesses the SIMD elements.
+ /// Also returns the number of elements.
+ pub fn operand_to_simd(
+ &self,
+ base: &OpTy<'tcx, M::PointerTag>,
+ ) -> InterpResult<'tcx, (MPlaceTy<'tcx, M::PointerTag>, u64)> {
+ // Basically we just transmute this place into an array following simd_size_and_type.
+ // This only works in memory, but repr(simd) types should never be immediates anyway.
+ assert!(base.layout.ty.is_simd());
+ self.mplace_to_simd(&base.assert_mem_place())
+ }
+
/// Read from a local. Will not actually access the local if reading from a ZST.
/// Will not access memory, instead an indirect `Operand` is returned.
///
}
} else {
// Go through the layout. There are lots of types that support a length,
- // e.g., SIMD types.
+ // e.g., SIMD types. (But not all repr(simd) types even have FieldsShape::Array!)
match self.layout.fields {
FieldsShape::Array { count, .. } => Ok(count),
_ => bug!("len not supported on sized type {:?}", self.layout.ty),
})
}
+ /// Converts a repr(simd) place into a place where `place_index` accesses the SIMD elements.
+ /// Also returns the number of elements.
+ pub fn mplace_to_simd(
+ &self,
+ base: &MPlaceTy<'tcx, M::PointerTag>,
+ ) -> InterpResult<'tcx, (MPlaceTy<'tcx, M::PointerTag>, u64)> {
+ // Basically we just transmute this place into an array following simd_size_and_type.
+ // (Transmuting is okay since this is an in-memory place. We also double-check the size
+ // stays the same.)
+ let (len, e_ty) = base.layout.ty.simd_size_and_type(*self.tcx);
+ let array = self.tcx.mk_array(e_ty, len);
+ let layout = self.layout_of(array)?;
+ assert_eq!(layout.size, base.layout.size);
+ Ok((MPlaceTy { layout, ..*base }, len))
+ }
+
/// Gets the place of a field inside the place, and also the field's type.
/// Just a convenience function, but used quite a bit.
/// This is the only projection that might have a side-effect: We cannot project
})
}
+ /// Converts a repr(simd) place into a place where `place_index` accesses the SIMD elements.
+ /// Also returns the number of elements.
+ pub fn place_to_simd(
+ &mut self,
+ base: &PlaceTy<'tcx, M::PointerTag>,
+ ) -> InterpResult<'tcx, (MPlaceTy<'tcx, M::PointerTag>, u64)> {
+ let mplace = self.force_allocation(base)?;
+ self.mplace_to_simd(&mplace)
+ }
+
/// Computes a place. You should only use this if you intend to write into this
/// place; for reading, a more efficient alternative is `eval_place_for_read`.
pub fn eval_place(
}
}
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Debug, PartialEq, Eq)]
pub(super) struct State {
/// Describes whether a local contains qualif.
pub qualif: BitSet<Local>,
pub borrow: BitSet<Local>,
}
+impl Clone for State {
+ fn clone(&self) -> Self {
+ State { qualif: self.qualif.clone(), borrow: self.borrow.clone() }
+ }
+
+ // Data flow engine when possible uses `clone_from` for domain values.
+ // Providing an implementation will avoid some intermediate memory allocations.
+ fn clone_from(&mut self, other: &Self) {
+ self.qualif.clone_from(&other.qualif);
+ self.borrow.clone_from(&other.borrow);
+ }
+}
+
impl State {
#[inline]
pub(super) fn contains(&self, local: Local) -> bool {
/// returned value in a promoted MIR, unless it's a subset
/// of a larger candidate.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
-pub enum Candidate {
- /// Borrow of a constant temporary, candidate for lifetime extension.
- Ref(Location),
-}
-
-impl Candidate {
- fn source_info(&self, body: &Body<'_>) -> SourceInfo {
- match self {
- Candidate::Ref(location) => *body.source_info(*location),
- }
- }
+pub struct Candidate {
+ location: Location,
}
struct Collector<'a, 'tcx> {
match *rvalue {
Rvalue::Ref(..) => {
- self.candidates.push(Candidate::Ref(location));
+ self.candidates.push(Candidate { location });
}
_ => {}
}
impl<'tcx> Validator<'_, 'tcx> {
fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
- match candidate {
- Candidate::Ref(loc) => {
- let statement = &self.body[loc.block].statements[loc.statement_index];
- match &statement.kind {
- StatementKind::Assign(box (_, Rvalue::Ref(_, kind, place))) => {
- // We can only promote interior borrows of promotable temps (non-temps
- // don't get promoted anyway).
- self.validate_local(place.local)?;
-
- // The reference operation itself must be promotable.
- // (Needs to come after `validate_local` to avoid ICEs.)
- self.validate_ref(*kind, place)?;
-
- // We do not check all the projections (they do not get promoted anyway),
- // but we do stay away from promoting anything involving a dereference.
- if place.projection.contains(&ProjectionElem::Deref) {
- return Err(Unpromotable);
- }
+ let loc = candidate.location;
+ let statement = &self.body[loc.block].statements[loc.statement_index];
+ match &statement.kind {
+ StatementKind::Assign(box (_, Rvalue::Ref(_, kind, place))) => {
+ // We can only promote interior borrows of promotable temps (non-temps
+ // don't get promoted anyway).
+ self.validate_local(place.local)?;
+
+ // The reference operation itself must be promotable.
+ // (Needs to come after `validate_local` to avoid ICEs.)
+ self.validate_ref(*kind, place)?;
- // We cannot promote things that need dropping, since the promoted value
- // would not get dropped.
- if self.qualif_local::<qualifs::NeedsDrop>(place.local) {
- return Err(Unpromotable);
- }
+ // We do not check all the projections (they do not get promoted anyway),
+ // but we do stay away from promoting anything involving a dereference.
+ if place.projection.contains(&ProjectionElem::Deref) {
+ return Err(Unpromotable);
+ }
- Ok(())
- }
- _ => bug!(),
+ // We cannot promote things that need dropping, since the promoted value
+ // would not get dropped.
+ if self.qualif_local::<qualifs::NeedsDrop>(place.local) {
+ return Err(Unpromotable);
}
+
+ Ok(())
}
+ _ => bug!(),
}
}
}))
};
let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut();
- match candidate {
- Candidate::Ref(loc) => {
- let statement = &mut blocks[loc.block].statements[loc.statement_index];
- match statement.kind {
- StatementKind::Assign(box (
- _,
- Rvalue::Ref(ref mut region, borrow_kind, ref mut place),
- )) => {
- // Use the underlying local for this (necessarily interior) borrow.
- let ty = local_decls.local_decls()[place.local].ty;
- let span = statement.source_info.span;
-
- let ref_ty = tcx.mk_ref(
- tcx.lifetimes.re_erased,
- ty::TypeAndMut { ty, mutbl: borrow_kind.to_mutbl_lossy() },
- );
-
- *region = tcx.lifetimes.re_erased;
-
- let mut projection = vec![PlaceElem::Deref];
- projection.extend(place.projection);
- place.projection = tcx.intern_place_elems(&projection);
-
- // Create a temp to hold the promoted reference.
- // This is because `*r` requires `r` to be a local,
- // otherwise we would use the `promoted` directly.
- let mut promoted_ref = LocalDecl::new(ref_ty, span);
- promoted_ref.source_info = statement.source_info;
- let promoted_ref = local_decls.push(promoted_ref);
- assert_eq!(self.temps.push(TempState::Unpromotable), promoted_ref);
-
- let promoted_ref_statement = Statement {
- source_info: statement.source_info,
- kind: StatementKind::Assign(Box::new((
- Place::from(promoted_ref),
- Rvalue::Use(promoted_operand(ref_ty, span)),
- ))),
- };
- self.extra_statements.push((loc, promoted_ref_statement));
-
- Rvalue::Ref(
- tcx.lifetimes.re_erased,
- borrow_kind,
- Place {
- local: mem::replace(&mut place.local, promoted_ref),
- projection: List::empty(),
- },
- )
- }
- _ => bug!(),
- }
+ let loc = candidate.location;
+ let statement = &mut blocks[loc.block].statements[loc.statement_index];
+ match statement.kind {
+ StatementKind::Assign(box (
+ _,
+ Rvalue::Ref(ref mut region, borrow_kind, ref mut place),
+ )) => {
+ // Use the underlying local for this (necessarily interior) borrow.
+ let ty = local_decls.local_decls()[place.local].ty;
+ let span = statement.source_info.span;
+
+ let ref_ty = tcx.mk_ref(
+ tcx.lifetimes.re_erased,
+ ty::TypeAndMut { ty, mutbl: borrow_kind.to_mutbl_lossy() },
+ );
+
+ *region = tcx.lifetimes.re_erased;
+
+ let mut projection = vec![PlaceElem::Deref];
+ projection.extend(place.projection);
+ place.projection = tcx.intern_place_elems(&projection);
+
+ // Create a temp to hold the promoted reference.
+ // This is because `*r` requires `r` to be a local,
+ // otherwise we would use the `promoted` directly.
+ let mut promoted_ref = LocalDecl::new(ref_ty, span);
+ promoted_ref.source_info = statement.source_info;
+ let promoted_ref = local_decls.push(promoted_ref);
+ assert_eq!(self.temps.push(TempState::Unpromotable), promoted_ref);
+
+ let promoted_ref_statement = Statement {
+ source_info: statement.source_info,
+ kind: StatementKind::Assign(Box::new((
+ Place::from(promoted_ref),
+ Rvalue::Use(promoted_operand(ref_ty, span)),
+ ))),
+ };
+ self.extra_statements.push((loc, promoted_ref_statement));
+
+ Rvalue::Ref(
+ tcx.lifetimes.re_erased,
+ borrow_kind,
+ Place {
+ local: mem::replace(&mut place.local, promoted_ref),
+ projection: List::empty(),
+ },
+ )
}
+ _ => bug!(),
}
};
let mut extra_statements = vec![];
for candidate in candidates.into_iter().rev() {
- match candidate {
- Candidate::Ref(Location { block, statement_index }) => {
- if let StatementKind::Assign(box (place, _)) =
- &body[block].statements[statement_index].kind
- {
- if let Some(local) = place.as_local() {
- if temps[local] == TempState::PromotedOut {
- // Already promoted.
- continue;
- }
- }
+ let Location { block, statement_index } = candidate.location;
+ if let StatementKind::Assign(box (place, _)) = &body[block].statements[statement_index].kind
+ {
+ if let Some(local) = place.as_local() {
+ if temps[local] == TempState::PromotedOut {
+ // Already promoted.
+ continue;
}
}
}
// Declare return place local so that `mir::Body::new` doesn't complain.
let initial_locals = iter::once(LocalDecl::new(tcx.types.never, body.span)).collect();
- let mut scope = body.source_scopes[candidate.source_info(body).scope].clone();
+ let mut scope = body.source_scopes[body.source_info(candidate.location).scope].clone();
scope.parent_scope = None;
let promoted = Body::new(
println!("{}", cfg);
}
}
- RelocationModels | CodeModels | TlsModels | TargetCPUs | TargetFeatures => {
+ RelocationModels
+ | CodeModels
+ | TlsModels
+ | TargetCPUs
+ | StackProtectorStrategies
+ | TargetFeatures => {
codegen_backend.print(*req, sess);
}
// Any output here interferes with Cargo's parsing of other printed output
}
self.msg_to_buffer(&mut buffer, msg, max_line_num_len, "note", None);
} else {
+ let mut label_width = 0;
// The failure note level itself does not provide any useful diagnostic information
if *level != Level::FailureNote {
buffer.append(0, level.to_str(), Style::Level(*level));
+ label_width += level.to_str().len();
}
// only render error codes, not lint codes
if let Some(DiagnosticId::Error(ref code)) = *code {
buffer.append(0, "[", Style::Level(*level));
buffer.append(0, &code, Style::Level(*level));
buffer.append(0, "]", Style::Level(*level));
+ label_width += 2 + code.len();
}
let header_style = if is_secondary { Style::HeaderMsg } else { Style::MainHeaderMsg };
if *level != Level::FailureNote {
buffer.append(0, ": ", header_style);
+ label_width += 2;
}
for &(ref text, _) in msg.iter() {
- buffer.append(0, &replace_tabs(text), header_style);
+ // Account for newlines to align output to its label.
+ for (line, text) in replace_tabs(text).lines().enumerate() {
+ buffer.append(
+ 0 + line,
+ &format!(
+ "{}{}",
+ if line == 0 { String::new() } else { " ".repeat(label_width) },
+ text
+ ),
+ header_style,
+ );
+ }
}
}
/// Allows associated types in inherent impls.
(incomplete, inherent_associated_types, "1.52.0", Some(8995), None),
/// Allow anonymous constants from an inline `const` block
- (incomplete, inline_const, "1.49.0", Some(76001), None),
+ (active, inline_const, "1.49.0", Some(76001), None),
+ /// Allow anonymous constants from an inline `const` block in pattern position
+ (incomplete, inline_const_pat, "1.58.0", Some(76001), None),
/// Allows using `pointer` and `reference` in intra-doc links
(active, intra_doc_pointers, "1.51.0", Some(80896), None),
/// Allows `#[instruction_set(_)]` attribute
//! Built-in attributes and `cfg` flag gating.
+use AttributeDuplicates::*;
use AttributeGate::*;
use AttributeType::*;
/// Only top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is considered now.
#[derive(Clone, Copy, Default)]
pub struct AttributeTemplate {
+ /// If `true`, the attribute is allowed to be a bare word like `#[test]`.
pub word: bool,
+ /// If `Some`, the attribute is allowed to take a list of items like `#[allow(..)]`.
pub list: Option<&'static str>,
+ /// If `Some`, the attribute is allowed to be a name/value pair where the
+ /// value is a string, like `#[must_use = "reason"]`.
pub name_value_str: Option<&'static str>,
}
+/// How to handle multiple duplicate attributes on the same item.
+#[derive(Clone, Copy, Default)]
+pub enum AttributeDuplicates {
+ /// Duplicates of this attribute are allowed.
+ ///
+ /// This should only be used with attributes where duplicates have semantic
+ /// meaning, or some kind of "additive" behavior. For example, `#[warn(..)]`
+ /// can be specified multiple times, and it combines all the entries. Or use
+ /// this if there is validation done elsewhere.
+ #[default]
+ DuplicatesOk,
+ /// Duplicates after the first attribute will be an unused_attribute warning.
+ ///
+ /// This is usually used for "word" attributes, where they are used as a
+ /// boolean marker, like `#[used]`. It is not necessarily wrong that there
+ /// are duplicates, but the others should probably be removed.
+ WarnFollowing,
+ /// Same as `WarnFollowing`, but only issues warnings for word-style attributes.
+ ///
+ /// This is only for special cases, for example multiple `#[macro_use]` can
+ /// be warned, but multiple `#[macro_use(...)]` should not because the list
+ /// form has different meaning from the word form.
+ WarnFollowingWordOnly,
+ /// Duplicates after the first attribute will be an error.
+ ///
+ /// This should be used where duplicates would be ignored, but carry extra
+ /// meaning that could cause confusion. For example, `#[stable(since="1.0")]
+ /// #[stable(since="2.0")]`, which version should be used for `stable`?
+ ErrorFollowing,
+ /// Duplicates preceding the last instance of the attribute will be an error.
+ ///
+ /// This is the same as `ErrorFollowing`, except the last attribute is the
+ /// one that is "used". This is typically used in cases like codegen
+ /// attributes which usually only honor the last attribute.
+ ErrorPreceding,
+ /// Duplicates after the first attribute will be an unused_attribute warning
+ /// with a note that this will be an error in the future.
+ ///
+ /// This should be used for attributes that should be `ErrorFollowing`, but
+ /// because older versions of rustc silently accepted (and ignored) the
+ /// attributes, this is used to transition.
+ FutureWarnFollowing,
+ /// Duplicates preceding the last instance of the attribute will be a
+ /// warning, with a note that this will be an error in the future.
+ ///
+ /// This is the same as `FutureWarnFollowing`, except the last attribute is
+ /// the one that is "used". Ideally these can eventually migrate to
+ /// `ErrorPreceding`.
+ FutureWarnPreceding,
+}
+
/// A convenience macro for constructing attribute templates.
/// E.g., `template!(Word, List: "description")` means that the attribute
/// supports forms `#[attr]` and `#[attr(description)]`.
}
macro_rules! ungated {
- ($attr:ident, $typ:expr, $tpl:expr $(,)?) => {
- BuiltinAttribute { name: sym::$attr, type_: $typ, template: $tpl, gate: Ungated }
+ ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr $(,)?) => {
+ BuiltinAttribute {
+ name: sym::$attr,
+ type_: $typ,
+ template: $tpl,
+ gate: Ungated,
+ duplicates: $duplicates,
+ }
};
}
macro_rules! gated {
- ($attr:ident, $typ:expr, $tpl:expr, $gate:ident, $msg:expr $(,)?) => {
+ ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $gate:ident, $msg:expr $(,)?) => {
BuiltinAttribute {
name: sym::$attr,
type_: $typ,
template: $tpl,
+ duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::$gate, $msg, cfg_fn!($gate)),
}
};
- ($attr:ident, $typ:expr, $tpl:expr, $msg:expr $(,)?) => {
+ ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $msg:expr $(,)?) => {
BuiltinAttribute {
name: sym::$attr,
type_: $typ,
template: $tpl,
+ duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::$attr, $msg, cfg_fn!($attr)),
}
};
}
macro_rules! rustc_attr {
- (TEST, $attr:ident, $typ:expr, $tpl:expr $(,)?) => {
+ (TEST, $attr:ident, $typ:expr, $tpl:expr, $duplicate:expr $(,)?) => {
rustc_attr!(
$attr,
$typ,
$tpl,
+ $duplicate,
concat!(
"the `#[",
stringify!($attr),
),
)
};
- ($attr:ident, $typ:expr, $tpl:expr, $msg:expr $(,)?) => {
+ ($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $msg:expr $(,)?) => {
BuiltinAttribute {
name: sym::$attr,
type_: $typ,
template: $tpl,
+ duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)),
}
};
pub name: Symbol,
pub type_: AttributeType,
pub template: AttributeTemplate,
+ pub duplicates: AttributeDuplicates,
pub gate: AttributeGate,
}
// ==========================================================================
// Conditional compilation:
- ungated!(cfg, Normal, template!(List: "predicate")),
- ungated!(cfg_attr, Normal, template!(List: "predicate, attr1, attr2, ...")),
+ ungated!(cfg, Normal, template!(List: "predicate"), DuplicatesOk),
+ ungated!(cfg_attr, Normal, template!(List: "predicate, attr1, attr2, ..."), DuplicatesOk),
// Testing:
- ungated!(ignore, Normal, template!(Word, NameValueStr: "reason")),
+ ungated!(ignore, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing),
ungated!(
should_panic, Normal,
- template!(Word, List: r#"expected = "reason"#, NameValueStr: "reason"),
+ template!(Word, List: r#"expected = "reason"#, NameValueStr: "reason"), FutureWarnFollowing,
),
// FIXME(Centril): This can be used on stable but shouldn't.
- ungated!(reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name")),
+ ungated!(reexport_test_harness_main, CrateLevel, template!(NameValueStr: "name"), ErrorFollowing),
// Macros:
- ungated!(automatically_derived, Normal, template!(Word)),
- // FIXME(#14407)
- ungated!(macro_use, Normal, template!(Word, List: "name1, name2, ...")),
- ungated!(macro_escape, Normal, template!(Word)), // Deprecated synonym for `macro_use`.
- ungated!(macro_export, Normal, template!(Word, List: "local_inner_macros")),
- ungated!(proc_macro, Normal, template!(Word)),
+ ungated!(automatically_derived, Normal, template!(Word), WarnFollowing),
+ ungated!(macro_use, Normal, template!(Word, List: "name1, name2, ..."), WarnFollowingWordOnly),
+ ungated!(macro_escape, Normal, template!(Word), WarnFollowing), // Deprecated synonym for `macro_use`.
+ ungated!(macro_export, Normal, template!(Word, List: "local_inner_macros"), WarnFollowing),
+ ungated!(proc_macro, Normal, template!(Word), ErrorFollowing),
ungated!(
proc_macro_derive, Normal,
- template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"),
+ template!(List: "TraitName, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
),
- ungated!(proc_macro_attribute, Normal, template!(Word)),
+ ungated!(proc_macro_attribute, Normal, template!(Word), ErrorFollowing),
// Lints:
- ungated!(warn, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)),
- ungated!(allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)),
- ungated!(forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)),
- ungated!(deny, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)),
- ungated!(must_use, Normal, template!(Word, NameValueStr: "reason")),
+ ungated!(
+ warn, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk
+ ),
+ ungated!(
+ allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk
+ ),
+ ungated!(
+ forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk
+ ),
+ ungated!(
+ deny, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk
+ ),
+ ungated!(must_use, Normal, template!(Word, NameValueStr: "reason"), FutureWarnFollowing),
gated!(
- must_not_suspend, Normal, template!(Word, NameValueStr: "reason"), must_not_suspend,
- experimental!(must_not_suspend)
+ must_not_suspend, Normal, template!(Word, NameValueStr: "reason"), WarnFollowing,
+ must_not_suspend, experimental!(must_not_suspend)
),
- // FIXME(#14407)
ungated!(
deprecated, Normal,
template!(
List: r#"/*opt*/ since = "version", /*opt*/ note = "reason""#,
NameValueStr: "reason"
),
+ // This has special duplicate handling in E0550 to handle duplicates with rustc_deprecated
+ DuplicatesOk
),
// Crate properties:
- ungated!(crate_name, CrateLevel, template!(NameValueStr: "name")),
- ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|...")),
- ungated!(crate_id, CrateLevel, template!(NameValueStr: "ignored")),
+ ungated!(crate_name, CrateLevel, template!(NameValueStr: "name"), FutureWarnFollowing),
+ ungated!(crate_type, CrateLevel, template!(NameValueStr: "bin|lib|..."), FutureWarnFollowing),
+ // crate_id is deprecated
+ ungated!(crate_id, CrateLevel, template!(NameValueStr: "ignored"), FutureWarnFollowing),
// ABI, linking, symbols, and FFI
ungated!(
link, Normal,
template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...""#),
+ DuplicatesOk,
),
- ungated!(link_name, Normal, template!(NameValueStr: "name")),
- ungated!(no_link, Normal, template!(Word)),
- ungated!(repr, Normal, template!(List: "C")),
- ungated!(export_name, Normal, template!(NameValueStr: "name")),
- ungated!(link_section, Normal, template!(NameValueStr: "name")),
- ungated!(no_mangle, Normal, template!(Word)),
- ungated!(used, Normal, template!(Word)),
+ ungated!(link_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
+ ungated!(no_link, Normal, template!(Word), WarnFollowing),
+ ungated!(repr, Normal, template!(List: "C"), DuplicatesOk),
+ ungated!(export_name, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
+ ungated!(link_section, Normal, template!(NameValueStr: "name"), FutureWarnPreceding),
+ ungated!(no_mangle, Normal, template!(Word), WarnFollowing),
+ ungated!(used, Normal, template!(Word), WarnFollowing),
// Limits:
- ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N")),
- ungated!(type_length_limit, CrateLevel, template!(NameValueStr: "N")),
+ ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
+ ungated!(type_length_limit, CrateLevel, template!(NameValueStr: "N"), FutureWarnFollowing),
gated!(
- const_eval_limit, CrateLevel, template!(NameValueStr: "N"), const_eval_limit,
- experimental!(const_eval_limit)
+ const_eval_limit, CrateLevel, template!(NameValueStr: "N"), ErrorFollowing,
+ const_eval_limit, experimental!(const_eval_limit)
),
gated!(
- move_size_limit, CrateLevel, template!(NameValueStr: "N"), large_assignments,
- experimental!(move_size_limit)
+ move_size_limit, CrateLevel, template!(NameValueStr: "N"), ErrorFollowing,
+ large_assignments, experimental!(move_size_limit)
),
// Entry point:
- ungated!(main, Normal, template!(Word)),
- ungated!(start, Normal, template!(Word)),
- ungated!(no_start, CrateLevel, template!(Word)),
- ungated!(no_main, CrateLevel, template!(Word)),
+ ungated!(main, Normal, template!(Word), WarnFollowing),
+ ungated!(start, Normal, template!(Word), WarnFollowing),
+ ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
+ ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),
// Modules, prelude, and resolution:
- ungated!(path, Normal, template!(NameValueStr: "file")),
- ungated!(no_std, CrateLevel, template!(Word)),
- ungated!(no_implicit_prelude, Normal, template!(Word)),
- ungated!(non_exhaustive, Normal, template!(Word)),
+ ungated!(path, Normal, template!(NameValueStr: "file"), FutureWarnFollowing),
+ ungated!(no_std, CrateLevel, template!(Word), WarnFollowing),
+ ungated!(no_implicit_prelude, Normal, template!(Word), WarnFollowing),
+ ungated!(non_exhaustive, Normal, template!(Word), WarnFollowing),
// Runtime
- ungated!(windows_subsystem, Normal, template!(NameValueStr: "windows|console")),
- ungated!(panic_handler, Normal, template!(Word)), // RFC 2070
+ ungated!(
+ windows_subsystem, Normal,
+ template!(NameValueStr: "windows|console"), FutureWarnFollowing
+ ),
+ ungated!(panic_handler, Normal, template!(Word), WarnFollowing), // RFC 2070
// Code generation:
- ungated!(inline, Normal, template!(Word, List: "always|never")),
- ungated!(cold, Normal, template!(Word)),
- ungated!(no_builtins, Normal, template!(Word)),
- ungated!(target_feature, Normal, template!(List: r#"enable = "name""#)),
- ungated!(track_caller, Normal, template!(Word)),
+ ungated!(inline, Normal, template!(Word, List: "always|never"), FutureWarnFollowing),
+ ungated!(cold, Normal, template!(Word), WarnFollowing),
+ ungated!(no_builtins, Normal, template!(Word), WarnFollowing),
+ ungated!(target_feature, Normal, template!(List: r#"enable = "name""#), DuplicatesOk),
+ ungated!(track_caller, Normal, template!(Word), WarnFollowing),
gated!(
no_sanitize, Normal,
- template!(List: "address, memory, thread"),
+ template!(List: "address, memory, thread"), DuplicatesOk,
experimental!(no_sanitize)
),
- gated!(no_coverage, Normal, template!(Word), experimental!(no_coverage)),
+ gated!(no_coverage, Normal, template!(Word), WarnFollowing, experimental!(no_coverage)),
- // FIXME: #14408 assume docs are used since rustdoc looks at them.
- ungated!(doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string")),
+ ungated!(
+ doc, Normal, template!(List: "hidden|inline|...", NameValueStr: "string"), DuplicatesOk
+ ),
// ==========================================================================
// Unstable attributes:
// ==========================================================================
// Linking:
- gated!(naked, Normal, template!(Word), naked_functions, experimental!(naked)),
+ gated!(naked, Normal, template!(Word), WarnFollowing, naked_functions, experimental!(naked)),
gated!(
- link_ordinal, Normal, template!(List: "ordinal"), raw_dylib,
+ link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding, raw_dylib,
experimental!(link_ordinal)
),
name: sym::plugin,
type_: CrateLevel,
template: template!(List: "name"),
+ duplicates: DuplicatesOk,
gate: Gated(
Stability::Deprecated(
"https://github.com/rust-lang/rust/pull/64675",
},
// Testing:
- gated!(allow_fail, Normal, template!(Word), experimental!(allow_fail)),
+ gated!(allow_fail, Normal, template!(Word), WarnFollowing, experimental!(allow_fail)),
gated!(
- test_runner, CrateLevel, template!(List: "path"), custom_test_frameworks,
+ test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,
"custom test frameworks are an unstable feature",
),
// RFC #1268
- gated!(marker, Normal, template!(Word), marker_trait_attr, experimental!(marker)),
gated!(
- thread_local, Normal, template!(Word),
+ marker, Normal, template!(Word), WarnFollowing, marker_trait_attr, experimental!(marker)
+ ),
+ gated!(
+ thread_local, Normal, template!(Word), WarnFollowing,
"`#[thread_local]` is an experimental feature, and does not currently handle destructors",
),
- gated!(no_core, CrateLevel, template!(Word), experimental!(no_core)),
+ gated!(no_core, CrateLevel, template!(Word), WarnFollowing, experimental!(no_core)),
// RFC 2412
gated!(
- optimize, Normal, template!(List: "size|speed"), optimize_attribute,
+ optimize, Normal, template!(List: "size|speed"), ErrorPreceding, optimize_attribute,
experimental!(optimize),
),
// RFC 2867
- gated!(instruction_set, Normal, template!(List: "set"), isa_attribute, experimental!(instruction_set)),
+ gated!(
+ instruction_set, Normal, template!(List: "set"), ErrorPreceding,
+ isa_attribute, experimental!(instruction_set)
+ ),
- gated!(ffi_returns_twice, Normal, template!(Word), experimental!(ffi_returns_twice)),
- gated!(ffi_pure, Normal, template!(Word), experimental!(ffi_pure)),
- gated!(ffi_const, Normal, template!(Word), experimental!(ffi_const)),
gated!(
- register_attr, CrateLevel, template!(List: "attr1, attr2, ..."),
+ ffi_returns_twice, Normal, template!(Word), WarnFollowing, experimental!(ffi_returns_twice)
+ ),
+ gated!(ffi_pure, Normal, template!(Word), WarnFollowing, experimental!(ffi_pure)),
+ gated!(ffi_const, Normal, template!(Word), WarnFollowing, experimental!(ffi_const)),
+ gated!(
+ register_attr, CrateLevel, template!(List: "attr1, attr2, ..."), DuplicatesOk,
experimental!(register_attr),
),
gated!(
- register_tool, CrateLevel, template!(List: "tool1, tool2, ..."),
+ register_tool, CrateLevel, template!(List: "tool1, tool2, ..."), DuplicatesOk,
experimental!(register_tool),
),
- gated!(cmse_nonsecure_entry, Normal, template!(Word), experimental!(cmse_nonsecure_entry)),
+ gated!(
+ cmse_nonsecure_entry, Normal, template!(Word), WarnFollowing,
+ experimental!(cmse_nonsecure_entry)
+ ),
// RFC 2632
gated!(
- default_method_body_is_const, Normal, template!(Word), const_trait_impl,
+ default_method_body_is_const, Normal, template!(Word), WarnFollowing, const_trait_impl,
"`default_method_body_is_const` is a temporary placeholder for declaring default bodies \
as `const`, which may be removed or renamed in the future."
),
// Internal attributes: Stability, deprecation, and unsafe:
// ==========================================================================
- ungated!(feature, CrateLevel, template!(List: "name1, name1, ...")),
- // FIXME(#14407) -- only looked at on-demand so we can't
- // guarantee they'll have already been checked.
+ ungated!(feature, CrateLevel, template!(List: "name1, name1, ..."), DuplicatesOk),
+ // DuplicatesOk since it has its own validation
ungated!(
rustc_deprecated, Normal,
- template!(List: r#"since = "version", reason = "...""#)
+ template!(List: r#"since = "version", reason = "...""#), DuplicatesOk // See E0550
+ ),
+ // DuplicatesOk since it has its own validation
+ ungated!(
+ stable, Normal, template!(List: r#"feature = "name", since = "version""#), DuplicatesOk
),
- // FIXME(#14407)
- ungated!(stable, Normal, template!(List: r#"feature = "name", since = "version""#)),
- // FIXME(#14407)
ungated!(
unstable, Normal,
- template!(List: r#"feature = "name", reason = "...", issue = "N""#),
+ template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk,
),
- // FIXME(#14407)
- ungated!(rustc_const_unstable, Normal, template!(List: r#"feature = "name""#)),
- // FIXME(#14407)
- ungated!(rustc_const_stable, Normal, template!(List: r#"feature = "name""#)),
+ ungated!(rustc_const_unstable, Normal, template!(List: r#"feature = "name""#), DuplicatesOk),
+ ungated!(rustc_const_stable, Normal, template!(List: r#"feature = "name""#), DuplicatesOk),
gated!(
- allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."),
+ allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,
"allow_internal_unstable side-steps feature gating and stability checks",
),
gated!(
- rustc_allow_const_fn_unstable, Normal, template!(Word, List: "feat1, feat2, ..."),
+ rustc_allow_const_fn_unstable, Normal,
+ template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,
"rustc_allow_const_fn_unstable side-steps feature gating and stability checks"
),
gated!(
- allow_internal_unsafe, Normal, template!(Word),
+ allow_internal_unsafe, Normal, template!(Word), WarnFollowing,
"allow_internal_unsafe side-steps the unsafe_code lint",
),
// Internal attributes: Type system related:
// ==========================================================================
- gated!(fundamental, Normal, template!(Word), experimental!(fundamental)),
+ gated!(fundamental, Normal, template!(Word), WarnFollowing, experimental!(fundamental)),
gated!(
- may_dangle, Normal, template!(Word), dropck_eyepatch,
+ may_dangle, Normal, template!(Word), WarnFollowing, dropck_eyepatch,
"`may_dangle` has unstable semantics and may be removed in the future",
),
// Internal attributes: Runtime related:
// ==========================================================================
- rustc_attr!(rustc_allocator, Normal, template!(Word), IMPL_DETAIL),
- rustc_attr!(rustc_allocator_nounwind, Normal, template!(Word), IMPL_DETAIL),
- gated!(alloc_error_handler, Normal, template!(Word), experimental!(alloc_error_handler)),
+ rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
+ rustc_attr!(rustc_allocator_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
+ gated!(
+ alloc_error_handler, Normal, template!(Word), WarnFollowing,
+ experimental!(alloc_error_handler)
+ ),
gated!(
- default_lib_allocator, Normal, template!(Word), allocator_internals,
+ default_lib_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
experimental!(default_lib_allocator),
),
gated!(
- needs_allocator, Normal, template!(Word), allocator_internals,
+ needs_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
experimental!(needs_allocator),
),
- gated!(panic_runtime, Normal, template!(Word), experimental!(panic_runtime)),
- gated!(needs_panic_runtime, Normal, template!(Word), experimental!(needs_panic_runtime)),
+ gated!(panic_runtime, Normal, template!(Word), WarnFollowing, experimental!(panic_runtime)),
gated!(
- compiler_builtins, Normal, template!(Word),
+ needs_panic_runtime, Normal, template!(Word), WarnFollowing,
+ experimental!(needs_panic_runtime)
+ ),
+ gated!(
+ compiler_builtins, Normal, template!(Word), WarnFollowing,
"the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
which contains compiler-rt intrinsics and will never be stable",
),
gated!(
- profiler_runtime, Normal, template!(Word),
+ profiler_runtime, Normal, template!(Word), WarnFollowing,
"the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
which contains the profiler runtime and will never be stable",
),
// ==========================================================================
gated!(
- linkage, Normal, template!(NameValueStr: "external|internal|..."),
+ linkage, Normal, template!(NameValueStr: "external|internal|..."), ErrorPreceding,
"the `linkage` attribute is experimental and not portable across platforms",
),
- rustc_attr!(rustc_std_internal_symbol, Normal, template!(Word), INTERNAL_UNSTABLE),
+ rustc_attr!(
+ rustc_std_internal_symbol, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
+ ),
// ==========================================================================
// Internal attributes, Macro related:
rustc_attr!(
rustc_builtin_macro, Normal,
- template!(Word, List: "name, /*opt*/ attributes(name1, name2, ...)"),
+ template!(Word, List: "name, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
IMPL_DETAIL,
),
- rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), INTERNAL_UNSTABLE),
+ rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
rustc_attr!(
rustc_macro_transparency, Normal,
- template!(NameValueStr: "transparent|semitransparent|opaque"),
+ template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing,
"used internally for testing macro hygiene",
),
List: r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
NameValueStr: "message"
),
+ ErrorFollowing,
INTERNAL_UNSTABLE
),
// Enumerates "identity-like" conversion methods to suggest on type mismatch.
- rustc_attr!(rustc_conversion_suggestion, Normal, template!(Word), INTERNAL_UNSTABLE),
+ rustc_attr!(
+ rustc_conversion_suggestion, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
+ ),
// Prevents field reads in the marked trait or method to be considered
// during dead code analysis.
- rustc_attr!(rustc_trivial_field_reads, Normal, template!(Word), INTERNAL_UNSTABLE),
+ rustc_attr!(
+ rustc_trivial_field_reads, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
+ ),
// ==========================================================================
// Internal attributes, Const related:
// ==========================================================================
- rustc_attr!(rustc_promotable, Normal, template!(Word), IMPL_DETAIL),
- rustc_attr!(rustc_legacy_const_generics, Normal, template!(List: "N"), INTERNAL_UNSTABLE),
+ rustc_attr!(rustc_promotable, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
+ rustc_attr!(
+ rustc_legacy_const_generics, Normal, template!(List: "N"), ErrorFollowing,
+ INTERNAL_UNSTABLE
+ ),
// Do not const-check this function's body. It will always get replaced during CTFE.
- rustc_attr!(rustc_do_not_const_check, Normal, template!(Word), INTERNAL_UNSTABLE),
+ rustc_attr!(
+ rustc_do_not_const_check, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE
+ ),
// ==========================================================================
// Internal attributes, Layout related:
// ==========================================================================
rustc_attr!(
- rustc_layout_scalar_valid_range_start, Normal, template!(List: "value"),
+ rustc_layout_scalar_valid_range_start, Normal, template!(List: "value"), ErrorFollowing,
"the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \
niche optimizations in libcore and will never be stable",
),
rustc_attr!(
- rustc_layout_scalar_valid_range_end, Normal, template!(List: "value"),
+ rustc_layout_scalar_valid_range_end, Normal, template!(List: "value"), ErrorFollowing,
"the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \
niche optimizations in libcore and will never be stable",
),
rustc_attr!(
- rustc_nonnull_optimization_guaranteed, Normal, template!(Word),
+ rustc_nonnull_optimization_guaranteed, Normal, template!(Word), WarnFollowing,
"the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable \
niche optimizations in libcore and will never be stable",
),
// Internal attributes, Misc:
// ==========================================================================
gated!(
- lang, Normal, template!(NameValueStr: "name"), lang_items,
+ lang, Normal, template!(NameValueStr: "name"), DuplicatesOk, lang_items,
"language items are subject to change",
),
BuiltinAttribute {
name: sym::rustc_diagnostic_item,
type_: Normal,
template: template!(NameValueStr: "name"),
+ duplicates: ErrorFollowing,
gate: Gated(
Stability::Unstable,
sym::rustc_attrs,
},
gated!(
// Used in resolve:
- prelude_import, Normal, template!(Word),
+ prelude_import, Normal, template!(Word), WarnFollowing,
"`#[prelude_import]` is for use by rustc only",
),
gated!(
- rustc_paren_sugar, Normal, template!(Word), unboxed_closures,
+ rustc_paren_sugar, Normal, template!(Word), WarnFollowing, unboxed_closures,
"unboxed_closures are still evolving",
),
rustc_attr!(
- rustc_inherit_overflow_checks, Normal, template!(Word),
+ rustc_inherit_overflow_checks, Normal, template!(Word), WarnFollowing,
"the `#[rustc_inherit_overflow_checks]` attribute is just used to control \
overflow checking behavior of several libcore functions that are inlined \
across crates and will never be stable",
),
- rustc_attr!(rustc_reservation_impl, Normal, template!(NameValueStr: "reservation message"),
- "the `#[rustc_reservation_impl]` attribute is internally used \
- for reserving for `for<T> From<!> for T` impl"
+ rustc_attr!(
+ rustc_reservation_impl, Normal,
+ template!(NameValueStr: "reservation message"), ErrorFollowing,
+ "the `#[rustc_reservation_impl]` attribute is internally used \
+ for reserving for `for<T> From<!> for T` impl"
),
rustc_attr!(
- rustc_test_marker, Normal, template!(Word),
+ rustc_test_marker, Normal, template!(Word), WarnFollowing,
"the `#[rustc_test_marker]` attribute is used internally to track tests",
),
rustc_attr!(
- rustc_unsafe_specialization_marker, Normal, template!(Word),
+ rustc_unsafe_specialization_marker, Normal, template!(Word), WarnFollowing,
"the `#[rustc_unsafe_specialization_marker]` attribute is used to check specializations"
),
rustc_attr!(
- rustc_specialization_trait, Normal, template!(Word),
+ rustc_specialization_trait, Normal, template!(Word), WarnFollowing,
"the `#[rustc_specialization_trait]` attribute is used to check specializations"
),
rustc_attr!(
- rustc_main, Normal, template!(Word),
+ rustc_main, Normal, template!(Word), WarnFollowing,
"the `#[rustc_main]` attribute is used internally to specify test entry point function",
),
rustc_attr!(
- rustc_skip_array_during_method_dispatch, Normal, template!(Word),
+ rustc_skip_array_during_method_dispatch, Normal, template!(Word), WarnFollowing,
"the `#[rustc_skip_array_during_method_dispatch]` attribute is used to exclude a trait \
from method dispatch when the receiver is an array, for compatibility in editions < 2021."
),
// Internal attributes, Testing:
// ==========================================================================
- rustc_attr!(TEST, rustc_outlives, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_capture_analysis, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_strict_coherence, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_variance, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ...")),
- rustc_attr!(TEST, rustc_regions, Normal, template!(Word)),
+ rustc_attr!(TEST, rustc_outlives, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_capture_analysis, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_strict_coherence, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_variance, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
+ rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
rustc_attr!(
TEST, rustc_error, Normal,
- template!(Word, List: "delay_span_bug_from_inside_query")
+ template!(Word, List: "delay_span_bug_from_inside_query"), WarnFollowingWordOnly
+ ),
+ rustc_attr!(TEST, rustc_dump_user_substs, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(
+ TEST, rustc_if_this_changed, Normal, template!(Word, List: "DepNode"), DuplicatesOk
+ ),
+ rustc_attr!(
+ TEST, rustc_then_this_would_need, Normal, template!(List: "DepNode"), DuplicatesOk
),
- rustc_attr!(TEST, rustc_dump_user_substs, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_if_this_changed, Normal, template!(Word, List: "DepNode")),
- rustc_attr!(TEST, rustc_then_this_would_need, Normal, template!(List: "DepNode")),
rustc_attr!(
TEST, rustc_clean, Normal,
template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#),
+ DuplicatesOk,
),
rustc_attr!(
TEST, rustc_partition_reused, Normal,
- template!(List: r#"cfg = "...", module = "...""#),
+ template!(List: r#"cfg = "...", module = "...""#), DuplicatesOk,
),
rustc_attr!(
TEST, rustc_partition_codegened, Normal,
- template!(List: r#"cfg = "...", module = "...""#),
+ template!(List: r#"cfg = "...", module = "...""#), DuplicatesOk,
),
rustc_attr!(
TEST, rustc_expected_cgu_reuse, Normal,
- template!(List: r#"cfg = "...", module = "...", kind = "...""#),
- ),
- rustc_attr!(TEST, rustc_synthetic, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_symbol_name, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_polymorphize_error, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_def_path, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_mir, Normal, template!(List: "arg1, arg2, ...")),
- rustc_attr!(TEST, rustc_dump_program_clauses, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_dump_env_program_clauses, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_object_lifetime_default, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_dump_vtable, Normal, template!(Word)),
- rustc_attr!(TEST, rustc_dummy, Normal, template!(Word /* doesn't matter*/)),
+ template!(List: r#"cfg = "...", module = "...", kind = "...""#), DuplicatesOk,
+ ),
+ rustc_attr!(TEST, rustc_symbol_name, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_polymorphize_error, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_def_path, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_mir, Normal, template!(List: "arg1, arg2, ..."), DuplicatesOk),
+ rustc_attr!(TEST, rustc_dump_program_clauses, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_dump_env_program_clauses, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_object_lifetime_default, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_dump_vtable, Normal, template!(Word), WarnFollowing),
+ rustc_attr!(TEST, rustc_dummy, Normal, template!(Word /* doesn't matter*/), DuplicatesOk),
gated!(
- omit_gdb_pretty_printer_section, Normal, template!(Word),
+ omit_gdb_pretty_printer_section, Normal, template!(Word), WarnFollowing,
"the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite",
),
];
//! even if it is stabilized or removed, *do not remove it*. Instead, move the
//! symbol to the `accepted` or `removed` modules respectively.
+#![feature(derive_default_enum)]
#![feature(once_cell)]
mod accepted;
pub use accepted::ACCEPTED_FEATURES;
pub use active::{Features, ACTIVE_FEATURES, INCOMPATIBLE_FEATURES};
+pub use builtin_attrs::AttributeDuplicates;
pub use builtin_attrs::{
deprecated_attributes, find_gated_cfg, is_builtin_attr_name, AttributeGate, AttributeTemplate,
AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
-/// This declares a list of types which can be allocated by `Arena`.
+/// This higher-order macro declares a list of types which can be allocated by `Arena`.
///
/// Specifying the `decode` modifier will add decode impls for `&T` and `&[T]`,
/// where `T` is the type listed. These impls will appear in the implement_ty_decoder! macro.
#[macro_export]
macro_rules! arena_types {
- ($macro:path, $tcx:lifetime) => (
+ ($macro:path) => (
$macro!([
// HIR types
- [] hir_krate: rustc_hir::Crate<$tcx>,
- [] arm: rustc_hir::Arm<$tcx>,
- [] asm_operand: (rustc_hir::InlineAsmOperand<$tcx>, Span),
+ [] hir_krate: rustc_hir::Crate<'tcx>,
+ [] arm: rustc_hir::Arm<'tcx>,
+ [] asm_operand: (rustc_hir::InlineAsmOperand<'tcx>, Span),
[] asm_template: rustc_ast::InlineAsmTemplatePiece,
[] attribute: rustc_ast::Attribute,
- [] block: rustc_hir::Block<$tcx>,
- [] bare_fn_ty: rustc_hir::BareFnTy<$tcx>,
- [] body: rustc_hir::Body<$tcx>,
- [] generic_arg: rustc_hir::GenericArg<$tcx>,
- [] generic_args: rustc_hir::GenericArgs<$tcx>,
- [] generic_bound: rustc_hir::GenericBound<$tcx>,
- [] generic_param: rustc_hir::GenericParam<$tcx>,
- [] expr: rustc_hir::Expr<$tcx>,
- [] expr_field: rustc_hir::ExprField<$tcx>,
- [] pat_field: rustc_hir::PatField<$tcx>,
- [] fn_decl: rustc_hir::FnDecl<$tcx>,
- [] foreign_item: rustc_hir::ForeignItem<$tcx>,
+ [] block: rustc_hir::Block<'tcx>,
+ [] bare_fn_ty: rustc_hir::BareFnTy<'tcx>,
+ [] body: rustc_hir::Body<'tcx>,
+ [] generic_arg: rustc_hir::GenericArg<'tcx>,
+ [] generic_args: rustc_hir::GenericArgs<'tcx>,
+ [] generic_bound: rustc_hir::GenericBound<'tcx>,
+ [] generic_param: rustc_hir::GenericParam<'tcx>,
+ [] expr: rustc_hir::Expr<'tcx>,
+ [] expr_field: rustc_hir::ExprField<'tcx>,
+ [] pat_field: rustc_hir::PatField<'tcx>,
+ [] fn_decl: rustc_hir::FnDecl<'tcx>,
+ [] foreign_item: rustc_hir::ForeignItem<'tcx>,
[] foreign_item_ref: rustc_hir::ForeignItemRef,
- [] impl_item: rustc_hir::ImplItem<$tcx>,
+ [] impl_item: rustc_hir::ImplItem<'tcx>,
[] impl_item_ref: rustc_hir::ImplItemRef,
- [] item: rustc_hir::Item<$tcx>,
- [] inline_asm: rustc_hir::InlineAsm<$tcx>,
- [] llvm_inline_asm: rustc_hir::LlvmInlineAsm<$tcx>,
- [] local: rustc_hir::Local<$tcx>,
- [] mod_: rustc_hir::Mod<$tcx>,
- [] owner_info: rustc_hir::OwnerInfo<$tcx>,
- [] param: rustc_hir::Param<$tcx>,
- [] pat: rustc_hir::Pat<$tcx>,
- [] path: rustc_hir::Path<$tcx>,
- [] path_segment: rustc_hir::PathSegment<$tcx>,
- [] poly_trait_ref: rustc_hir::PolyTraitRef<$tcx>,
- [] qpath: rustc_hir::QPath<$tcx>,
- [] stmt: rustc_hir::Stmt<$tcx>,
- [] field_def: rustc_hir::FieldDef<$tcx>,
- [] trait_item: rustc_hir::TraitItem<$tcx>,
+ [] item: rustc_hir::Item<'tcx>,
+ [] inline_asm: rustc_hir::InlineAsm<'tcx>,
+ [] llvm_inline_asm: rustc_hir::LlvmInlineAsm<'tcx>,
+ [] local: rustc_hir::Local<'tcx>,
+ [] mod_: rustc_hir::Mod<'tcx>,
+ [] owner_info: rustc_hir::OwnerInfo<'tcx>,
+ [] param: rustc_hir::Param<'tcx>,
+ [] pat: rustc_hir::Pat<'tcx>,
+ [] path: rustc_hir::Path<'tcx>,
+ [] path_segment: rustc_hir::PathSegment<'tcx>,
+ [] poly_trait_ref: rustc_hir::PolyTraitRef<'tcx>,
+ [] qpath: rustc_hir::QPath<'tcx>,
+ [] stmt: rustc_hir::Stmt<'tcx>,
+ [] field_def: rustc_hir::FieldDef<'tcx>,
+ [] trait_item: rustc_hir::TraitItem<'tcx>,
[] trait_item_ref: rustc_hir::TraitItemRef,
- [] ty: rustc_hir::Ty<$tcx>,
- [] type_binding: rustc_hir::TypeBinding<$tcx>,
- [] variant: rustc_hir::Variant<$tcx>,
- [] where_predicate: rustc_hir::WherePredicate<$tcx>,
- ], $tcx);
+ [] ty: rustc_hir::Ty<'tcx>,
+ [] type_binding: rustc_hir::TypeBinding<'tcx>,
+ [] variant: rustc_hir::Variant<'tcx>,
+ [] where_predicate: rustc_hir::WherePredicate<'tcx>,
+ ]);
)
}
},
Type {
default: Option<&'hir Ty<'hir>>,
- synthetic: Option<SyntheticTyParamKind>,
+ synthetic: bool,
},
Const {
ty: &'hir Ty<'hir>,
}
}
-/// Synthetic type parameters are converted to another form during lowering; this allows
-/// us to track the original form they had, and is useful for error messages.
-#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
-#[derive(HashStable_Generic)]
-pub enum SyntheticTyParamKind {
- ImplTrait,
- // Created by the `#[rustc_synthetic]` attribute.
- FromAttr,
-}
-
/// A where-clause in a definition.
#[derive(Debug, HashStable_Generic)]
pub struct WhereClause<'hir> {
pub enum LocalSource {
/// A `match _ { .. }`.
Normal,
- /// A desugared `for _ in _ { .. }` loop.
- ForLoopDesugar,
/// When lowering async functions, we create locals within the `async move` so that
/// all parameters are dropped after the future is polled.
///
use crate::def_id::DefId;
use crate::hir::{self, HirId, PatKind};
use rustc_data_structures::stable_set::FxHashSet;
+use rustc_span::hygiene::DesugaringKind;
use rustc_span::symbol::Ident;
use rustc_span::Span;
});
result
}
+
+ /// If the pattern is `Some(<pat>)` from a desugared for loop, returns the inner pattern
+ pub fn for_loop_some(&self) -> Option<&Self> {
+ if self.span.desugaring_kind() == Some(DesugaringKind::ForLoop) {
+ if let hir::PatKind::Struct(_, [pat_field], _) = self.kind {
+ return Some(pat_field.pat);
+ }
+ }
+ None
+ }
}
use rustc_middle::ty::OnDiskCache;
use rustc_serialize::opaque::Decoder;
use rustc_serialize::Decodable;
+use rustc_session::config::IncrementalStateAssertion;
use rustc_session::Session;
use std::path::Path;
type WorkProductMap = FxHashMap<WorkProductId, WorkProduct>;
+#[derive(Debug)]
pub enum LoadResult<T> {
Ok { data: T },
DataOutOfDate,
impl<T: Default> LoadResult<T> {
pub fn open(self, sess: &Session) -> T {
+ // Check for errors when using `-Zassert-incremental-state`
+ match (sess.opts.assert_incr_state, &self) {
+ (Some(IncrementalStateAssertion::NotLoaded), LoadResult::Ok { .. }) => {
+ sess.fatal(
+ "We asserted that the incremental cache should not be loaded, \
+ but it was loaded.",
+ );
+ }
+ (
+ Some(IncrementalStateAssertion::Loaded),
+ LoadResult::Error { .. } | LoadResult::DataOutOfDate,
+ ) => {
+ sess.fatal(
+ "We asserted that an existing incremental cache directory should \
+ be successfully loaded, but it was not.",
+ );
+ }
+ _ => {}
+ };
+
match self {
LoadResult::Error { message } => {
sess.warn(&message);
if let Err(err) = delete_all_session_dir_contents(sess) {
sess.err(&format!(
"Failed to delete invalidated or incompatible \
- incremental compilation session directory contents `{}`: {}.",
+ incremental compilation session directory contents `{}`: {}.",
dep_graph_path(sess).display(),
err
));
err
}
+/// Structurally compares two types, modulo any inference variables.
+///
+/// Returns `true` if two types are equal, or if one type is an inference variable compatible
+/// with the other type. A TyVar inference type is compatible with any type, and an IntVar or
+/// FloatVar inference type are compatible with themselves or their concrete types (Int and
+/// Float types, respectively). When comparing two ADTs, these rules apply recursively.
+pub fn same_type_modulo_infer(a: Ty<'tcx>, b: Ty<'ctx>) -> bool {
+ match (&a.kind(), &b.kind()) {
+ (&ty::Adt(did_a, substs_a), &ty::Adt(did_b, substs_b)) => {
+ if did_a != did_b {
+ return false;
+ }
+
+ substs_a.types().zip(substs_b.types()).all(|(a, b)| same_type_modulo_infer(a, b))
+ }
+ (&ty::Int(_), &ty::Infer(ty::InferTy::IntVar(_)))
+ | (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Int(_) | &ty::Infer(ty::InferTy::IntVar(_)))
+ | (&ty::Float(_), &ty::Infer(ty::InferTy::FloatVar(_)))
+ | (
+ &ty::Infer(ty::InferTy::FloatVar(_)),
+ &ty::Float(_) | &ty::Infer(ty::InferTy::FloatVar(_)),
+ )
+ | (&ty::Infer(ty::InferTy::TyVar(_)), _)
+ | (_, &ty::Infer(ty::InferTy::TyVar(_))) => true,
+ _ => a == b,
+ }
+}
+
impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn report_region_errors(&self, errors: &Vec<RegionResolutionError<'tcx>>) {
debug!("report_region_errors(): {} errors to start", errors.len());
}
_ => exp_found,
};
- debug!("exp_found {:?} terr {:?}", exp_found, terr);
+ debug!("exp_found {:?} terr {:?} cause.code {:?}", exp_found, terr, cause.code);
if let Some(exp_found) = exp_found {
- self.suggest_as_ref_where_appropriate(span, &exp_found, diag);
- self.suggest_accessing_field_where_appropriate(cause, &exp_found, diag);
- self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
+ let should_suggest_fixes = if let ObligationCauseCode::Pattern { root_ty, .. } =
+ &cause.code
+ {
+ // Skip if the root_ty of the pattern is not the same as the expected_ty.
+ // If these types aren't equal then we've probably peeled off a layer of arrays.
+ same_type_modulo_infer(self.resolve_vars_if_possible(*root_ty), exp_found.expected)
+ } else {
+ true
+ };
+
+ if should_suggest_fixes {
+ self.suggest_as_ref_where_appropriate(span, &exp_found, diag);
+ self.suggest_accessing_field_where_appropriate(cause, &exp_found, diag);
+ self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
+ }
}
// In some (most?) cases cause.body_id points to actual body, but in some cases
self.get_impl_future_output_ty(exp_found.expected),
self.get_impl_future_output_ty(exp_found.found),
) {
- (Some(exp), Some(found)) if ty::TyS::same_type(exp, found) => match &cause.code {
+ (Some(exp), Some(found)) if same_type_modulo_infer(exp, found) => match &cause.code {
ObligationCauseCode::IfExpression(box IfExpressionCause { then, .. }) => {
diag.multipart_suggestion(
"consider `await`ing on both `Future`s",
diag.help("consider `await`ing on both `Future`s");
}
},
- (_, Some(ty)) if ty::TyS::same_type(exp_found.expected, ty) => {
+ (_, Some(ty)) if same_type_modulo_infer(exp_found.expected, ty) => {
diag.span_suggestion_verbose(
exp_span.shrink_to_hi(),
"consider `await`ing on the `Future`",
Applicability::MaybeIncorrect,
);
}
- (Some(ty), _) if ty::TyS::same_type(ty, exp_found.found) => match cause.code {
+ (Some(ty), _) if same_type_modulo_infer(ty, exp_found.found) => match cause.code {
ObligationCauseCode::Pattern { span: Some(span), .. }
| ObligationCauseCode::IfExpression(box IfExpressionCause { then: span, .. }) => {
diag.span_suggestion_verbose(
.iter()
.filter(|field| field.vis.is_accessible_from(field.did, self.tcx))
.map(|field| (field.ident.name, field.ty(self.tcx, expected_substs)))
- .find(|(_, ty)| ty::TyS::same_type(ty, exp_found.found))
+ .find(|(_, ty)| same_type_modulo_infer(ty, exp_found.found))
{
if let ObligationCauseCode::Pattern { span: Some(span), .. } = cause.code {
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
| (_, ty::Infer(_))
| (ty::Param(_), _)
| (ty::Infer(_), _) => {}
- _ if ty::TyS::same_type(exp_ty, found_ty) => {}
+ _ if same_type_modulo_infer(exp_ty, found_ty) => {}
_ => show_suggestion = false,
};
}
None
},
self.tcx.generics_of(owner.to_def_id()),
+ hir.span(hir_id),
)
});
+
+ let span = match generics {
+ // This is to get around the trait identity obligation, that has a `DUMMY_SP` as signal
+ // for other diagnostics, so we need to recover it here.
+ Some((_, _, node)) if span.is_dummy() => node,
+ _ => span,
+ };
+
let type_param_span = match (generics, bound_kind) {
- (Some((_, ref generics)), GenericKind::Param(ref param)) => {
+ (Some((_, ref generics, _)), GenericKind::Param(ref param)) => {
// Account for the case where `param` corresponds to `Self`,
// which doesn't have the expected type argument.
if !(generics.has_self && param.index == 0) {
};
let new_lt = generics
.as_ref()
- .and_then(|(parent_g, g)| {
+ .and_then(|(parent_g, g, _)| {
let mut possible = (b'a'..=b'z').map(|c| format!("'{}", c as char));
let mut lts_names = g
.params
.unwrap_or("'lt".to_string());
let add_lt_sugg = generics
.as_ref()
- .and_then(|(_, g)| g.params.first())
+ .and_then(|(_, g, _)| g.params.first())
.and_then(|param| param.def_id.as_local())
.map(|def_id| {
(
use rustc_hir::def::{DefKind, Namespace};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
-use rustc_hir::{Body, Expr, ExprKind, FnRetTy, HirId, Local, Pat};
+use rustc_hir::{Body, Expr, ExprKind, FnRetTy, HirId, Local, MatchSource, Pat};
use rustc_middle::hir::map::Map;
use rustc_middle::infer::unify_key::ConstVariableOriginKind;
use rustc_middle::ty::print::Print;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, DefIdTree, InferConst, Ty, TyCtxt};
-use rustc_span::source_map::DesugaringKind;
use rustc_span::symbol::kw;
use rustc_span::Span;
use std::borrow::Cow;
found_closure: Option<&'tcx Expr<'tcx>>,
found_method_call: Option<&'tcx Expr<'tcx>>,
found_exact_method_call: Option<&'tcx Expr<'tcx>>,
+ found_for_loop_iter: Option<&'tcx Expr<'tcx>>,
found_use_diagnostic: Option<UseDiagnostic<'tcx>>,
}
found_closure: None,
found_method_call: None,
found_exact_method_call: None,
+ found_for_loop_iter: None,
found_use_diagnostic: None,
}
}
}
fn visit_expr(&mut self, expr: &'tcx Expr<'tcx>) {
+ if let ExprKind::Match(scrutinee, [_, arm], MatchSource::ForLoopDesugar) = expr.kind {
+ if let Some(pat) = arm.pat.for_loop_some() {
+ if let Some(ty) = self.node_ty_contains_target(pat.hir_id) {
+ self.found_for_loop_iter = Some(scrutinee);
+ self.found_node_ty = Some(ty);
+ return;
+ }
+ }
+ }
if let ExprKind::MethodCall(_, call_span, exprs, _) = expr.kind {
if call_span == self.target_span
&& Some(self.target)
let msg = if let Some(simple_ident) = pattern.simple_ident() {
match pattern.span.desugaring_kind() {
None => format!("consider giving `{}` {}", simple_ident, suffix),
- Some(DesugaringKind::ForLoop(_)) => {
- "the element type for this iterator is not specified".to_string()
- }
- _ => format!("this needs {}", suffix),
+ Some(_) => format!("this needs {}", suffix),
}
} else {
format!("consider giving this pattern {}", suffix)
// = note: type must be known at this point
self.annotate_method_call(segment, e, &mut err);
}
+ } else if let Some(scrutinee) = local_visitor.found_for_loop_iter {
+ err.span_label(
+ scrutinee.span,
+ "the element type for this iterator is not specified".to_string(),
+ );
}
// Instead of the following:
// error[E0282]: type annotations needed
ObligationCauseCode::MatchImpl(parent, ..) => &parent.code,
_ => &cause.code,
};
- if let ObligationCauseCode::ItemObligation(item_def_id) = *code {
+ if let (ObligationCauseCode::ItemObligation(item_def_id), None) =
+ (code, override_error_code)
+ {
// Same case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a `'static`
// lifetime as above, but called using a fully-qualified path to the method:
// `Foo::qux(bar)`.
let mut v = TraitObjectVisitor(FxHashSet::default());
v.visit_ty(param.param_ty);
if let Some((ident, self_ty)) =
- self.get_impl_ident_and_self_ty_from_trait(item_def_id, &v.0)
+ self.get_impl_ident_and_self_ty_from_trait(*item_def_id, &v.0)
{
if self.suggest_constrain_dyn_trait_in_impl(&mut err, &v.0, ident, self_ty) {
override_error_code = Some(ident);
/// This is used so that the region values inferred by HIR region solving are
/// not exposed, and so that we can avoid doing work in HIR typeck that MIR
/// typeck will also do.
-#[derive(Copy, Clone, Debug)]
+#[derive(Copy, Clone, Debug, Default)]
pub enum RegionckMode {
/// The default mode: report region errors, don't erase regions.
+ #[default]
Solve,
/// Erase the results of region after solving.
Erase {
},
}
-impl Default for RegionckMode {
- fn default() -> Self {
- RegionckMode::Solve
- }
-}
-
impl RegionckMode {
/// Indicates that the MIR borrowck will repeat these region
/// checks, so we should ignore errors if NLL is (unconditionally)
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(bool_to_option)]
#![feature(box_patterns)]
+#![feature(derive_default_enum)]
#![feature(extend_one)]
#![feature(iter_zip)]
#![feature(let_else)]
use rustc_span::symbol::sym;
use rustc_span::SourceFileHashAlgorithm;
use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
-use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, TlsModel};
+use rustc_target::spec::{
+ RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel,
+};
use std::collections::{BTreeMap, BTreeSet};
use std::iter::FromIterator;
// Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
// This list is in alphabetical order.
+ untracked!(assert_incr_state, Some(String::from("loaded")));
untracked!(ast_json, true);
untracked!(ast_json_noexpand, true);
untracked!(borrowck, String::from("other"));
// This list is in alphabetical order.
tracked!(allow_features, Some(vec![String::from("lang_items")]));
tracked!(always_encode_mir, true);
- tracked!(assume_incomplete_release, true);
tracked!(asm_comments, true);
+ tracked!(assume_incomplete_release, true);
tracked!(binary_dep_depinfo, true);
tracked!(chalk, true);
tracked!(codegen_backend, Some("abc".to_string()));
tracked!(human_readable_cgu_names, true);
tracked!(inline_in_all_cgus, Some(true));
tracked!(inline_mir, Some(true));
- tracked!(inline_mir_threshold, Some(123));
tracked!(inline_mir_hint_threshold, Some(123));
+ tracked!(inline_mir_threshold, Some(123));
tracked!(instrument_coverage, Some(InstrumentCoverage::All));
tracked!(instrument_mcount, true);
tracked!(link_only, true);
tracked!(panic_abort_tests, true);
tracked!(panic_in_drop, PanicStrategy::Abort);
tracked!(partially_uninit_const_threshold, Some(123));
+ tracked!(pick_stable_methods_before_any_unstable, false);
tracked!(plt, Some(true));
tracked!(polonius, true);
tracked!(precise_enum_drop_elaboration, false);
tracked!(relax_elf_relocations, Some(true));
tracked!(relro_level, Some(RelroLevel::Full));
tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
- tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
tracked!(report_delayed_bugs, true);
tracked!(sanitizer, SanitizerSet::ADDRESS);
tracked!(sanitizer_memory_track_origins, 2);
tracked!(saturating_float_casts, Some(true));
tracked!(share_generics, Some(true));
tracked!(show_span, Some(String::from("abc")));
+ tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
+ tracked!(stack_protector, StackProtector::All);
tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
tracked!(teach, true);
tracked!(thinlto, Some(true));
tracked!(thir_unsafeck, true);
- tracked!(tune_cpu, Some(String::from("abc")));
tracked!(tls_model, Some(TlsModel::GeneralDynamic));
tracked!(trap_unreachable, Some(false));
tracked!(treat_err_as_bug, NonZeroUsize::new(1));
+ tracked!(tune_cpu, Some(String::from("abc")));
tracked!(unleash_the_miri_inside_of_you, true);
tracked!(use_ctors_section, Some(true));
tracked!(verify_llvm_ir, true);
InaccessibleMemOnly = 27,
SanitizeHWAddress = 28,
WillReturn = 29,
+ StackProtectReq = 30,
+ StackProtectStrong = 31,
+ StackProtect = 32,
};
typedef struct OpaqueRustString *RustStringRef;
extern "C" LLVMValueRef
LLVMRustGetOrInsertGlobal(LLVMModuleRef M, const char *Name, size_t NameLen, LLVMTypeRef Ty) {
+ Module *Mod = unwrap(M);
StringRef NameRef(Name, NameLen);
- return wrap(unwrap(M)->getOrInsertGlobal(NameRef, unwrap(Ty)));
+
+ // We don't use Module::getOrInsertGlobal because that returns a Constant*,
+ // which may either be the real GlobalVariable*, or a constant bitcast of it
+ // if our type doesn't match the original declaration. We always want the
+ // GlobalVariable* so we can access linkage, visibility, etc.
+ GlobalVariable *GV = Mod->getGlobalVariable(NameRef, true);
+ if (!GV)
+ GV = new GlobalVariable(*Mod, unwrap(Ty), false,
+ GlobalValue::ExternalLinkage, nullptr, NameRef);
+ return wrap(GV);
}
extern "C" LLVMValueRef
return Attribute::SanitizeHWAddress;
case WillReturn:
return Attribute::WillReturn;
+ case StackProtectReq:
+ return Attribute::StackProtectReq;
+ case StackProtectStrong:
+ return Attribute::StackProtectStrong;
+ case StackProtect:
+ return Attribute::StackProtect;
}
report_fatal_error("bad AttributeKind");
}
})
.collect();
- let result = quote! { ::rustc_serialize::Encoder::emit_enum_variant(
- __encoder,
- #variant_name,
- #variant_idx,
- #field_idx,
- |__encoder| { ::std::result::Result::Ok({ #encode_fields }) }
- ) };
+ let result = if field_idx != 0 {
+ quote! {
+ ::rustc_serialize::Encoder::emit_enum_variant(
+ __encoder,
+ #variant_name,
+ #variant_idx,
+ #field_idx,
+ |__encoder| { ::std::result::Result::Ok({ #encode_fields }) }
+ )
+ }
+ } else {
+ quote! {
+ ::rustc_serialize::Encoder::emit_fieldless_enum_variant::<#variant_idx>(
+ __encoder,
+ #variant_name,
+ )
+ }
+ };
variant_idx += 1;
result
});
-/// This declares a list of types which can be allocated by `Arena`.
+/// This higher-order macro declares a list of types which can be allocated by `Arena`.
///
/// Specifying the `decode` modifier will add decode impls for `&T` and `&[T]` where `T` is the type
/// listed. These impls will appear in the implement_ty_decoder! macro.
#[macro_export]
macro_rules! arena_types {
- ($macro:path, $tcx:lifetime) => (
+ ($macro:path) => (
$macro!([
[] layout: rustc_target::abi::Layout,
- [] fn_abi: rustc_target::abi::call::FnAbi<$tcx, rustc_middle::ty::Ty<$tcx>>,
+ [] fn_abi: rustc_target::abi::call::FnAbi<'tcx, rustc_middle::ty::Ty<'tcx>>,
// AdtDef are interned and compared by address
[] adt_def: rustc_middle::ty::AdtDef,
- [] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<$tcx>>,
- [] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<$tcx>>,
- [decode] mir: rustc_middle::mir::Body<$tcx>,
+ [] steal_thir: rustc_data_structures::steal::Steal<rustc_middle::thir::Thir<'tcx>>,
+ [] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<'tcx>>,
+ [decode] mir: rustc_middle::mir::Body<'tcx>,
[] steal_promoted:
rustc_data_structures::steal::Steal<
rustc_index::vec::IndexVec<
rustc_middle::mir::Promoted,
- rustc_middle::mir::Body<$tcx>
+ rustc_middle::mir::Body<'tcx>
>
>,
[decode] promoted:
rustc_index::vec::IndexVec<
rustc_middle::mir::Promoted,
- rustc_middle::mir::Body<$tcx>
+ rustc_middle::mir::Body<'tcx>
>,
- [decode] typeck_results: rustc_middle::ty::TypeckResults<$tcx>,
+ [decode] typeck_results: rustc_middle::ty::TypeckResults<'tcx>,
[decode] borrowck_result:
- rustc_middle::mir::BorrowCheckResult<$tcx>,
+ rustc_middle::mir::BorrowCheckResult<'tcx>,
[decode] unsafety_check_result: rustc_middle::mir::UnsafetyCheckResult,
[decode] code_region: rustc_middle::mir::coverage::CodeRegion,
[] const_allocs: rustc_middle::mir::interpret::Allocation,
[] foreign_modules: Vec<rustc_session::cstore::ForeignModule>,
[] upvars_mentioned: rustc_data_structures::fx::FxIndexMap<rustc_hir::HirId, rustc_hir::Upvar>,
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
- [] codegen_unit: rustc_middle::mir::mono::CodegenUnit<$tcx>,
+ [] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>,
[] attribute: rustc_ast::Attribute,
[] name_set: rustc_data_structures::fx::FxHashSet<rustc_span::symbol::Symbol>,
[] hir_id_set: rustc_hir::HirIdSet,
// Interned types
- [] tys: rustc_middle::ty::TyS<$tcx>,
- [] predicates: rustc_middle::ty::PredicateInner<$tcx>,
+ [] tys: rustc_middle::ty::TyS<'tcx>,
+ [] predicates: rustc_middle::ty::PredicateInner<'tcx>,
// Note that this deliberately duplicates items in the `rustc_hir::arena`,
// since we need to allocate this type on both the `rustc_hir` arena
[decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
[] dep_kind: rustc_middle::dep_graph::DepKindStruct,
- ], $tcx);
+ ]);
)
}
-arena_types!(rustc_arena::declare_arena, 'tcx);
+arena_types!(rustc_arena::declare_arena);
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(core_intrinsics)]
+#![feature(derive_default_enum)]
#![feature(discriminant_kind)]
#![feature(exhaustive_patterns)]
#![feature(if_let_guard)]
match expn_data.kind {
ExpnKind::Inlined
| ExpnKind::Root
- | ExpnKind::Desugaring(DesugaringKind::ForLoop(_) | DesugaringKind::WhileLoop) => false,
+ | ExpnKind::Desugaring(DesugaringKind::ForLoop | DesugaringKind::WhileLoop) => false,
ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external"
ExpnKind::Macro(MacroKind::Bang, _) => {
// Dummy span for the `def_site` means it's an external macro.
pub use self::StabilityLevel::*;
-use crate::ty::{self, TyCtxt};
+use crate::ty::{self, DefIdTree, TyCtxt};
use rustc_ast::NodeId;
use rustc_attr::{self as attr, ConstStability, Deprecation, Stability};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
feature: Symbol,
reason: Option<Symbol>,
issue: Option<NonZeroU32>,
+ suggestion: Option<(Span, String, String, Applicability)>,
is_soft: bool,
span: Span,
soft_handler: impl FnOnce(&'static Lint, Span, &str),
if is_soft {
soft_handler(SOFT_UNSTABLE, span, &msg)
} else {
- feature_err_issue(&sess.parse_sess, feature, span, GateIssue::Library(issue), &msg)
- .emit();
+ let mut err =
+ feature_err_issue(&sess.parse_sess, feature, span, GateIssue::Library(issue), &msg);
+ if let Some((inner_types, ref msg, sugg, applicability)) = suggestion {
+ err.span_suggestion(inner_types, msg, sugg, applicability);
+ }
+ err.emit();
}
}
}
Allow,
/// We cannot use the item because it is unstable and we did not provide the
/// corresponding feature gate.
- Deny { feature: Symbol, reason: Option<Symbol>, issue: Option<NonZeroU32>, is_soft: bool },
+ Deny {
+ feature: Symbol,
+ reason: Option<Symbol>,
+ issue: Option<NonZeroU32>,
+ suggestion: Option<(Span, String, String, Applicability)>,
+ is_soft: bool,
+ },
/// The item does not have the `#[stable]` or `#[unstable]` marker assigned.
Unmarked,
}
}
}
+// See issue #83250.
+fn suggestion_for_allocator_api(
+ tcx: TyCtxt<'_>,
+ def_id: DefId,
+ span: Span,
+ feature: Symbol,
+) -> Option<(Span, String, String, Applicability)> {
+ if feature == sym::allocator_api {
+ if let Some(trait_) = tcx.parent(def_id) {
+ if tcx.is_diagnostic_item(sym::Vec, trait_) {
+ let sm = tcx.sess.parse_sess.source_map();
+ let inner_types = sm.span_extend_to_prev_char(span, '<', true);
+ if let Ok(snippet) = sm.span_to_snippet(inner_types) {
+ return Some((
+ inner_types,
+ "consider wrapping the inner types in tuple".to_string(),
+ format!("({})", snippet),
+ Applicability::MaybeIncorrect,
+ ));
+ }
+ }
+ }
+ }
+ None
+}
+
impl<'tcx> TyCtxt<'tcx> {
/// Evaluates the stability of an item.
///
}
}
- EvalResult::Deny { feature, reason, issue, is_soft }
+ let suggestion = suggestion_for_allocator_api(self, def_id, span, feature);
+ EvalResult::Deny { feature, reason, issue, suggestion, is_soft }
}
Some(_) => {
// Stable APIs are always ok to call and deprecated APIs are
};
match self.eval_stability(def_id, id, span, method_span) {
EvalResult::Allow => {}
- EvalResult::Deny { feature, reason, issue, is_soft } => {
- report_unstable(self.sess, feature, reason, issue, is_soft, span, soft_handler)
- }
+ EvalResult::Deny { feature, reason, issue, suggestion, is_soft } => report_unstable(
+ self.sess,
+ feature,
+ reason,
+ issue,
+ suggestion,
+ is_soft,
+ span,
+ soft_handler,
+ ),
EvalResult::Unmarked => unmarked(span, def_id),
}
}
use std::borrow::Cow;
use std::fmt;
+use std::hash::{Hash, Hasher};
use std::ops::Deref;
pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache};
}
}
-#[derive(Clone, Debug, PartialEq, Eq, Hash, Lift)]
+#[derive(Clone, Debug, PartialEq, Eq, Lift)]
pub struct ObligationCauseData<'tcx> {
pub span: Span,
pub code: ObligationCauseCode<'tcx>,
}
+impl Hash for ObligationCauseData<'_> {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.body_id.hash(state);
+ self.span.hash(state);
+ std::mem::discriminant(&self.code).hash(state);
+ }
+}
+
impl<'tcx> ObligationCause<'tcx> {
#[inline]
pub fn new(
macro_rules! impl_arena_allocatable_decoder {
([]$args:tt) => {};
([decode $(, $attrs:ident)*]
- [[$name:ident: $ty:ty], $tcx:lifetime]) => {
- impl<$tcx, D: TyDecoder<$tcx>> RefDecodable<$tcx, D> for $ty {
+ [$name:ident: $ty:ty]) => {
+ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for $ty {
#[inline]
- fn decode(decoder: &mut D) -> Result<&$tcx Self, D::Error> {
+ fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
decode_arena_allocable(decoder)
}
}
- impl<$tcx, D: TyDecoder<$tcx>> RefDecodable<$tcx, D> for [$ty] {
+ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [$ty] {
#[inline]
- fn decode(decoder: &mut D) -> Result<&$tcx Self, D::Error> {
+ fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
decode_arena_allocable_slice(decoder)
}
}
}
macro_rules! impl_arena_allocatable_decoders {
- ([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) => {
+ ([$($a:tt $name:ident: $ty:ty,)*]) => {
$(
- impl_arena_allocatable_decoder!($a [[$name: $ty], $tcx]);
+ impl_arena_allocatable_decoder!($a [$name: $ty]);
)*
}
}
-rustc_hir::arena_types!(impl_arena_allocatable_decoders, 'tcx);
-arena_types!(impl_arena_allocatable_decoders, 'tcx);
+rustc_hir::arena_types!(impl_arena_allocatable_decoders);
+arena_types!(impl_arena_allocatable_decoders);
#[macro_export]
macro_rules! implement_ty_decoder {
use crate::ty::subst::{Subst, SubstsRef};
use rustc_ast as ast;
use rustc_data_structures::fx::FxHashMap;
-use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_span::symbol::Symbol;
use rustc_span::Span;
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
pub enum GenericParamDefKind {
Lifetime,
- Type {
- has_default: bool,
- object_lifetime_default: ObjectLifetimeDefault,
- synthetic: Option<hir::SyntheticTyParamKind>,
- },
- Const {
- has_default: bool,
- },
+ Type { has_default: bool, object_lifetime_default: ObjectLifetimeDefault, synthetic: bool },
+ Const { has_default: bool },
}
impl GenericParamDefKind {
/// Returns `true` if `params` has `impl Trait`.
pub fn has_impl_trait(&'tcx self) -> bool {
self.params.iter().any(|param| {
- matches!(
- param.kind,
- ty::GenericParamDefKind::Type {
- synthetic: Some(
- hir::SyntheticTyParamKind::ImplTrait | hir::SyntheticTyParamKind::FromAttr,
- ),
- ..
- }
- )
+ matches!(param.kind, ty::GenericParamDefKind::Type { synthetic: true, .. })
})
}
}
let mut first = true;
let mut is_sized = false;
+ let mut is_future = false;
+ let mut future_output_ty = None;
+
p!("impl");
for (predicate, _) in bounds {
let predicate = predicate.subst(self.tcx(), substs);
let bound_predicate = predicate.kind();
- if let ty::PredicateKind::Trait(pred) = bound_predicate.skip_binder() {
- let trait_ref = bound_predicate.rebind(pred.trait_ref);
- // Don't print +Sized, but rather +?Sized if absent.
- if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait() {
- is_sized = true;
- continue;
+
+ match bound_predicate.skip_binder() {
+ ty::PredicateKind::Projection(projection_predicate) => {
+ let Some(future_trait) = self.tcx().lang_items().future_trait() else { continue };
+ let future_output_def_id =
+ self.tcx().associated_item_def_ids(future_trait)[0];
+
+ if projection_predicate.projection_ty.item_def_id
+ == future_output_def_id
+ {
+ // We don't account for multiple `Future::Output = Ty` contraints.
+ is_future = true;
+ future_output_ty = Some(projection_predicate.ty);
+ }
}
+ ty::PredicateKind::Trait(pred) => {
+ let trait_ref = bound_predicate.rebind(pred.trait_ref);
+ // Don't print +Sized, but rather +?Sized if absent.
+ if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait()
+ {
+ is_sized = true;
+ continue;
+ }
- p!(
- write("{}", if first { " " } else { "+" }),
- print(trait_ref.print_only_trait_path())
- );
- first = false;
+ if Some(trait_ref.def_id())
+ == self.tcx().lang_items().future_trait()
+ {
+ is_future = true;
+ continue;
+ }
+
+ p!(
+ write("{}", if first { " " } else { " + " }),
+ print(trait_ref.print_only_trait_path())
+ );
+
+ first = false;
+ }
+ _ => {}
}
}
+
+ if is_future {
+ p!(write("{}Future", if first { " " } else { " + " }));
+ first = false;
+
+ if let Some(future_output_ty) = future_output_ty {
+ // Don't print projection types, which we (unfortunately) see often
+ // in the error outputs involving async blocks.
+ if !matches!(future_output_ty.kind(), ty::Projection(_)) {
+ p!("<Output = ", print(future_output_ty), ">");
+ }
+ }
+ }
+
if !is_sized {
- p!(write("{}?Sized", if first { " " } else { "+" }));
+ p!(write("{}?Sized", if first { " " } else { " + " }));
} else if first {
p!(" Sized");
}
+
Ok(self)
});
}
pub fn simd_size_and_type(&self, tcx: TyCtxt<'tcx>) -> (u64, Ty<'tcx>) {
match self.kind() {
Adt(def, substs) => {
+ assert!(def.repr.simd(), "`simd_size_and_type` called on non-SIMD type");
let variant = def.non_enum_variant();
let f0_ty = variant.fields[0].ty(tcx, substs);
match f0_ty.kind() {
+ // If the first field is an array, we assume it is the only field and its
+ // elements are the SIMD components.
Array(f0_elem_ty, f0_len) => {
// FIXME(repr_simd): https://github.com/rust-lang/rust/pull/78863#discussion_r522784112
// The way we evaluate the `N` in `[T; N]` here only works since we use
// if we use it in generic code. See the `simd-array-trait` ui test.
(f0_len.eval_usize(tcx, ParamEnv::empty()) as u64, f0_elem_ty)
}
+ // Otherwise, the fields of this Adt are the SIMD components (and we assume they
+ // all have the same type).
_ => (variant.fields.len() as u64, f0_ty),
}
}
/// a miscompilation or unsoundness.
///
/// When in doubt, use `VarianceDiagInfo::default()`
-#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
pub enum VarianceDiagInfo<'tcx> {
/// No additional information - this is the default.
/// We will not add any additional information to error messages.
+ #[default]
None,
/// We switched our variance because a type occurs inside
/// the generic argument of a mutable reference or pointer
}
}
}
-
-impl<'tcx> Default for VarianceDiagInfo<'tcx> {
- fn default() -> Self {
- Self::None
- }
-}
// encounter a candidate where the test is not relevant; at
// that point, we stop sorting.
while let Some(candidate) = candidates.first_mut() {
- if let Some(idx) = self.sort_candidate(&match_place.clone(), &test, candidate) {
- let (candidate, rest) = candidates.split_first_mut().unwrap();
- target_candidates[idx].push(candidate);
- candidates = rest;
- } else {
+ let Some(idx) = self.sort_candidate(&match_place.clone(), &test, candidate) else {
break;
- }
+ };
+ let (candidate, rest) = candidates.split_first_mut().unwrap();
+ target_candidates[idx].push(candidate);
+ candidates = rest;
}
// at least the first candidate ought to be tested
assert!(total_candidate_count > candidates.len());
DropKind::Value,
);
- if let Some(arg) = arg_opt {
- let pat = match tcx.hir().get(arg.pat.hir_id) {
- Node::Pat(pat) | Node::Binding(pat) => pat,
- node => bug!("pattern became {:?}", node),
- };
- let pattern = pat_from_hir(tcx, self.param_env, self.typeck_results, pat);
- let original_source_scope = self.source_scope;
- let span = pattern.span;
- self.set_correct_source_scope_for_arg(arg.hir_id, original_source_scope, span);
- match *pattern.kind {
- // Don't introduce extra copies for simple bindings
- PatKind::Binding {
- mutability,
- var,
- mode: BindingMode::ByValue,
- subpattern: None,
- ..
- } => {
- self.local_decls[local].mutability = mutability;
- self.local_decls[local].source_info.scope = self.source_scope;
- self.local_decls[local].local_info = if let Some(kind) = self_binding {
- Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
- BindingForm::ImplicitSelf(*kind),
- ))))
- } else {
- let binding_mode = ty::BindingMode::BindByValue(mutability);
- Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
- VarBindingForm {
- binding_mode,
- opt_ty_info,
- opt_match_place: Some((Some(place), span)),
- pat_span: span,
- },
- )))))
- };
- self.var_indices.insert(var, LocalsForNode::One(local));
- }
- _ => {
- scope = self.declare_bindings(
- scope,
- expr.span,
- &pattern,
- matches::ArmHasGuard(false),
- Some((Some(&place), span)),
- );
- let place_builder = PlaceBuilder::from(local);
- unpack!(
- block = self.place_into_pattern(block, pattern, place_builder, false)
- );
- }
+ let Some(arg) = arg_opt else {
+ continue;
+ };
+ let pat = match tcx.hir().get(arg.pat.hir_id) {
+ Node::Pat(pat) | Node::Binding(pat) => pat,
+ node => bug!("pattern became {:?}", node),
+ };
+ let pattern = pat_from_hir(tcx, self.param_env, self.typeck_results, pat);
+ let original_source_scope = self.source_scope;
+ let span = pattern.span;
+ self.set_correct_source_scope_for_arg(arg.hir_id, original_source_scope, span);
+ match *pattern.kind {
+ // Don't introduce extra copies for simple bindings
+ PatKind::Binding {
+ mutability,
+ var,
+ mode: BindingMode::ByValue,
+ subpattern: None,
+ ..
+ } => {
+ self.local_decls[local].mutability = mutability;
+ self.local_decls[local].source_info.scope = self.source_scope;
+ self.local_decls[local].local_info = if let Some(kind) = self_binding {
+ Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(
+ BindingForm::ImplicitSelf(*kind),
+ ))))
+ } else {
+ let binding_mode = ty::BindingMode::BindByValue(mutability);
+ Some(Box::new(LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
+ VarBindingForm {
+ binding_mode,
+ opt_ty_info,
+ opt_match_place: Some((Some(place), span)),
+ pat_span: span,
+ },
+ )))))
+ };
+ self.var_indices.insert(var, LocalsForNode::One(local));
+ }
+ _ => {
+ scope = self.declare_bindings(
+ scope,
+ expr.span,
+ &pattern,
+ matches::ArmHasGuard(false),
+ Some((Some(&place), span)),
+ );
+ let place_builder = PlaceBuilder::from(local);
+ unpack!(block = self.place_into_pattern(block, pattern, place_builder, false));
}
- self.source_scope = original_source_scope;
}
+ self.source_scope = original_source_scope;
}
// Enter the argument pattern bindings source scope, if it exists.
}
PatKind::Binding { mode: BindingMode::ByRef(borrow_kind), ty, .. } => {
if self.inside_adt {
- if let ty::Ref(_, ty, _) = ty.kind() {
- match borrow_kind {
- BorrowKind::Shallow | BorrowKind::Shared | BorrowKind::Unique => {
- if !ty.is_freeze(self.tcx.at(pat.span), self.param_env) {
- self.requires_unsafe(pat.span, BorrowOfLayoutConstrainedField);
- }
- }
- BorrowKind::Mut { .. } => {
- self.requires_unsafe(pat.span, MutationOfLayoutConstrainedField);
- }
- }
- } else {
+ let ty::Ref(_, ty, _) = ty.kind() else {
span_bug!(
pat.span,
"BindingMode::ByRef in pattern, but found non-reference type {}",
ty
);
+ };
+ match borrow_kind {
+ BorrowKind::Shallow | BorrowKind::Shared | BorrowKind::Unique => {
+ if !ty.is_freeze(self.tcx.at(pat.span), self.param_env) {
+ self.requires_unsafe(pat.span, BorrowOfLayoutConstrainedField);
+ }
+ }
+ BorrowKind::Mut { .. } => {
+ self.requires_unsafe(pat.span, MutationOfLayoutConstrainedField);
+ }
}
}
visit::walk_pat(self, pat);
let (msg, sp) = match loc.source {
hir::LocalSource::Normal => ("local binding", Some(loc.span)),
- hir::LocalSource::ForLoopDesugar => ("`for` loop binding", None),
hir::LocalSource::AsyncFn => ("async fn binding", None),
hir::LocalSource::AwaitDesugar => ("`await` future binding", None),
hir::LocalSource::AssignDesugar(_) => ("destructuring assignment binding", None),
};
self.check_irrefutable(&loc.pat, msg, sp);
- self.check_patterns(&loc.pat, Irrefutable);
}
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
intravisit::walk_param(self, param);
self.check_irrefutable(¶m.pat, "function argument", None);
- self.check_patterns(¶m.pat, Irrefutable);
}
}
fn check_match(
&mut self,
scrut: &hir::Expr<'_>,
- arms: &'tcx [hir::Arm<'tcx>],
+ hir_arms: &'tcx [hir::Arm<'tcx>],
source: hir::MatchSource,
) {
let mut cx = self.new_cx(scrut.hir_id);
- for arm in arms {
+ for arm in hir_arms {
// Check the arm for some things unrelated to exhaustiveness.
self.check_patterns(&arm.pat, Refutable);
if let Some(hir::Guard::IfLet(ref pat, _)) = arm.guard {
let mut have_errors = false;
- let arms: Vec<_> = arms
+ let arms: Vec<_> = hir_arms
.iter()
.map(|hir::Arm { pat, guard, .. }| MatchArm {
pat: self.lower_pattern(&mut cx, pat, &mut have_errors),
let report = compute_match_usefulness(&cx, &arms, scrut.hir_id, scrut_ty);
match source {
+ // Don't report arm reachability of desugared `match $iter.into_iter() { iter => .. }`
+ // when the iterator is an uninhabited type. unreachable_code will trigger instead.
+ hir::MatchSource::ForLoopDesugar if arms.len() == 1 => {}
hir::MatchSource::ForLoopDesugar | hir::MatchSource::Normal => {
report_arm_reachability(&cx, &report)
}
let is_empty_match = arms.is_empty();
let witnesses = report.non_exhaustiveness_witnesses;
if !witnesses.is_empty() {
- non_exhaustive_match(&cx, scrut_ty, scrut.span, witnesses, is_empty_match);
+ if source == hir::MatchSource::ForLoopDesugar && hir_arms.len() == 2 {
+ // the for loop pattern is not irrefutable
+ let pat = hir_arms[1].pat.for_loop_some().unwrap();
+ self.check_irrefutable(pat, "`for` loop binding", None);
+ } else {
+ non_exhaustive_match(&cx, scrut_ty, scrut.span, witnesses, is_empty_match);
+ }
}
}
let witnesses = report.non_exhaustiveness_witnesses;
if witnesses.is_empty() {
// The pattern is irrefutable.
+ self.check_patterns(pat, Irrefutable);
return;
}
use rustc_index::bit_set::BitSet;
use rustc_index::vec::Idx;
+use rustc_middle::mir::visit::{MirVisitable, Visitor};
use rustc_middle::mir::{self, Body, Location};
use rustc_middle::ty::{self, TyCtxt};
-use crate::drop_flag_effects;
use crate::drop_flag_effects_for_function_entry;
use crate::drop_flag_effects_for_location;
use crate::elaborate_drops::DropFlagState;
use crate::framework::SwitchIntEdgeEffects;
-use crate::move_paths::{HasMoveData, InitIndex, InitKind, MoveData, MovePathIndex};
+use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
use crate::on_lookup_result_bits;
use crate::MoveDataParamEnv;
+use crate::{drop_flag_effects, on_all_children_bits};
use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis};
mod borrowed_locals;
fn statement_effect(
&self,
trans: &mut impl GenKill<Self::Idx>,
- _statement: &mir::Statement<'tcx>,
+ statement: &mir::Statement<'tcx>,
location: Location,
) {
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
Self::update_bits(trans, path, s)
+ });
+
+ if !self.tcx.sess.opts.debugging_opts.precise_enum_drop_elaboration {
+ return;
+ }
+
+ // Mark all places as "maybe init" if they are mutably borrowed. See #90752.
+ for_each_mut_borrow(statement, location, |place| {
+ let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref()) else { return };
+ on_all_children_bits(self.tcx, self.body, self.move_data(), mpi, |child| {
+ trans.gen(child);
+ })
})
}
fn terminator_effect(
&self,
trans: &mut impl GenKill<Self::Idx>,
- _terminator: &mir::Terminator<'tcx>,
+ terminator: &mir::Terminator<'tcx>,
location: Location,
) {
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
Self::update_bits(trans, path, s)
+ });
+
+ if !self.tcx.sess.opts.debugging_opts.precise_enum_drop_elaboration {
+ return;
+ }
+
+ for_each_mut_borrow(terminator, location, |place| {
+ let LookupResult::Exact(mpi) = self.move_data().rev_lookup.find(place.as_ref()) else { return };
+ on_all_children_bits(self.tcx, self.body, self.move_data(), mpi, |child| {
+ trans.gen(child);
+ })
})
}
) {
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
Self::update_bits(trans, path, s)
- })
+ });
+
+ // Unlike in `MaybeInitializedPlaces` above, we don't need to change the state when a
+ // mutable borrow occurs. Places cannot become uninitialized through a mutable reference.
}
fn terminator_effect(
) {
drop_flag_effects_for_location(self.tcx, self.body, self.mdpe, location, |path, s| {
Self::update_bits(trans, path, s)
- })
+ });
}
fn call_return_effect(
_ => None,
}
}
+
+struct OnMutBorrow<F>(F);
+
+impl<F> Visitor<'_> for OnMutBorrow<F>
+where
+ F: FnMut(&mir::Place<'_>),
+{
+ fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'_>, location: Location) {
+ // FIXME: Does `&raw const foo` allow mutation? See #90413.
+ match rvalue {
+ mir::Rvalue::Ref(_, mir::BorrowKind::Mut { .. }, place)
+ | mir::Rvalue::AddressOf(_, place) => (self.0)(place),
+
+ _ => {}
+ }
+
+ self.super_rvalue(rvalue, location)
+ }
+}
+
+/// Calls `f` for each mutable borrow or raw reference in the program.
+///
+/// This DOES NOT call `f` for a shared borrow of a type with interior mutability. That's okay for
+/// initializedness, because we cannot move from an `UnsafeCell` (outside of `core::cell`), but
+/// other analyses will likely need to check for `!Freeze`.
+fn for_each_mut_borrow<'tcx>(
+ mir: &impl MirVisitable<'tcx>,
+ location: Location,
+ f: impl FnMut(&mir::Place<'_>),
+) {
+ let mut vis = OnMutBorrow(f);
+
+ mir.apply(location, &mut vis);
+}
[IdentLike(_), Punct('+' | '-')] |
// 1e+2 | 1e-2
[IdentLike(_), Punct('+' | '-'), IdentLike(_)] |
+ // 1.2e+ | 1.2e-
+ [IdentLike(_), Punct('.'), IdentLike(_), Punct('+' | '-')] |
// 1.2e+3 | 1.2e-3
[IdentLike(_), Punct('.'), IdentLike(_), Punct('+' | '-'), IdentLike(_)] => {
// See the FIXME about `TokenCursor` above.
} else if self.eat_keyword(kw::Unsafe) {
self.parse_block_expr(None, lo, BlockCheckMode::Unsafe(ast::UserProvided), attrs)
} else if self.check_inline_const(0) {
- self.parse_const_block(lo.to(self.token.span))
+ self.parse_const_block(lo.to(self.token.span), false)
} else if self.is_do_catch_block() {
self.recover_do_catch(attrs)
} else if self.is_try_block() {
}
/// Parses inline const expressions.
- fn parse_const_block(&mut self, span: Span) -> PResult<'a, P<Expr>> {
- self.sess.gated_spans.gate(sym::inline_const, span);
+ fn parse_const_block(&mut self, span: Span, pat: bool) -> PResult<'a, P<Expr>> {
+ if pat {
+ self.sess.gated_spans.gate(sym::inline_const_pat, span);
+ } else {
+ self.sess.gated_spans.gate(sym::inline_const, span);
+ }
self.eat_keyword(kw::Const);
let blk = self.parse_block()?;
let anon_const = AnonConst {
PatKind::Box(pat)
} else if self.check_inline_const(0) {
// Parse `const pat`
- let const_expr = self.parse_const_block(lo.to(self.token.span))?;
+ let const_expr = self.parse_const_block(lo.to(self.token.span), true)?;
if let Some(re) = self.parse_range_end() {
self.parse_pat_range_begin_with(const_expr, re)?
// Ensure the user doesn't receive unhelpful unexpected token errors
self.bump();
if self.is_pat_range_end_start(0) {
- let _ = self.parse_pat_range_end();
+ let _ = self.parse_pat_range_end().map_err(|mut e| e.cancel());
}
self.error_inclusive_range_with_extra_equals(span_with_eq);
fn parse_pat_range_end(&mut self) -> PResult<'a, P<Expr>> {
if self.check_inline_const(0) {
- self.parse_const_block(self.token.span)
+ self.parse_const_block(self.token.span, true)
} else if self.check_path() {
let lo = self.token.span;
let (qself, path) = if self.eat_lt() {
use rustc_middle::ty::TyCtxt;
use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, NestedMetaItem};
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{pluralize, struct_span_err, Applicability};
-use rustc_feature::{AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
+use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_session::parse::feature_err;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{MultiSpan, Span, DUMMY_SP};
+use std::collections::hash_map::Entry;
pub(crate) fn target_from_impl_item<'tcx>(
tcx: TyCtxt<'tcx>,
let mut doc_aliases = FxHashMap::default();
let mut is_valid = true;
let mut specified_inline = None;
- let mut seen = FxHashSet::default();
+ let mut seen = FxHashMap::default();
let attrs = self.tcx.hir().attrs(hir_id);
for attr in attrs {
let attr_is_valid = match attr.name_or_empty() {
_ => {}
}
+ let builtin = attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name));
+
if hir_id != CRATE_HIR_ID {
if let Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) =
attr.ident().and_then(|ident| BUILTIN_ATTRIBUTE_MAP.get(&ident.name))
}
}
- // Duplicate attributes
- match attr.name_or_empty() {
- name @ sym::macro_use => {
- let args = attr.meta_item_list().unwrap_or_else(Vec::new);
- let args: Vec<_> = args.iter().map(|arg| arg.name_or_empty()).collect();
- if !seen.insert((name, args)) {
- self.tcx.struct_span_lint_hir(
- UNUSED_ATTRIBUTES,
- hir_id,
+ if let Some(BuiltinAttribute { duplicates, .. }) = builtin {
+ check_duplicates(self.tcx, attr, hir_id, *duplicates, &mut seen);
+ }
+
+ // Warn on useless empty attributes.
+ if matches!(
+ attr.name_or_empty(),
+ sym::macro_use
+ | sym::allow
+ | sym::warn
+ | sym::deny
+ | sym::forbid
+ | sym::feature
+ | sym::repr
+ | sym::target_feature
+ ) && attr.meta_item_list().map_or(false, |list| list.is_empty())
+ {
+ self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
+ lint.build("unused attribute")
+ .span_suggestion(
attr.span,
- |lint| lint.build("unused attribute").emit(),
- );
- }
- }
- _ => {}
+ "remove this attribute",
+ String::new(),
+ Applicability::MachineApplicable,
+ )
+ .note(&format!(
+ "attribute `{}` with an empty list has no effect",
+ attr.name_or_empty()
+ ))
+ .emit();
+ });
}
}
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_mod_attrs, ..*providers };
}
+
+fn check_duplicates(
+ tcx: TyCtxt<'_>,
+ attr: &Attribute,
+ hir_id: HirId,
+ duplicates: AttributeDuplicates,
+ seen: &mut FxHashMap<Symbol, Span>,
+) {
+ use AttributeDuplicates::*;
+ if matches!(duplicates, WarnFollowingWordOnly) && !attr.is_word() {
+ return;
+ }
+ match duplicates {
+ DuplicatesOk => {}
+ WarnFollowing | FutureWarnFollowing | WarnFollowingWordOnly | FutureWarnPreceding => {
+ match seen.entry(attr.name_or_empty()) {
+ Entry::Occupied(mut entry) => {
+ let (this, other) = if matches!(duplicates, FutureWarnPreceding) {
+ let to_remove = entry.insert(attr.span);
+ (to_remove, attr.span)
+ } else {
+ (attr.span, *entry.get())
+ };
+ tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, this, |lint| {
+ let mut db = lint.build("unused attribute");
+ db.span_note(other, "attribute also specified here").span_suggestion(
+ this,
+ "remove this attribute",
+ String::new(),
+ Applicability::MachineApplicable,
+ );
+ if matches!(duplicates, FutureWarnFollowing | FutureWarnPreceding) {
+ db.warn(
+ "this was previously accepted by the compiler but is \
+ being phased out; it will become a hard error in \
+ a future release!",
+ );
+ }
+ db.emit();
+ });
+ }
+ Entry::Vacant(entry) => {
+ entry.insert(attr.span);
+ }
+ }
+ }
+ ErrorFollowing | ErrorPreceding => match seen.entry(attr.name_or_empty()) {
+ Entry::Occupied(mut entry) => {
+ let (this, other) = if matches!(duplicates, ErrorPreceding) {
+ let to_remove = entry.insert(attr.span);
+ (to_remove, attr.span)
+ } else {
+ (attr.span, *entry.get())
+ };
+ tcx.sess
+ .struct_span_err(
+ this,
+ &format!("multiple `{}` attributes", attr.name_or_empty()),
+ )
+ .span_note(other, "attribute also specified here")
+ .span_suggestion(
+ this,
+ "remove this attribute",
+ String::new(),
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ }
+ Entry::Vacant(entry) => {
+ entry.insert(attr.span);
+ }
+ },
+ }
+}
#![feature(let_else)]
#![feature(min_specialization)]
#![feature(thread_local_const_init)]
+#![feature(extern_types)]
#[macro_use]
extern crate tracing;
use rustc_data_structures::sync::{Lock, LockGuard};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{DiagnosticBuilder, FatalError};
+use rustc_session::Session;
use rustc_span::{Span, DUMMY_SP};
use std::cell::Cell;
use std::collections::hash_map::Entry;
debug!("END verify_ich({:?})", dep_node);
if Some(new_hash) != old_hash {
- let run_cmd = if let Some(crate_name) = &tcx.sess().opts.crate_name {
- format!("`cargo clean -p {}` or `cargo clean`", crate_name)
- } else {
- "`cargo clean`".to_string()
- };
+ incremental_verify_ich_cold(tcx.sess(), DebugArg::from(&dep_node), DebugArg::from(&result));
+ }
+}
- // When we emit an error message and panic, we try to debug-print the `DepNode`
- // and query result. Unforunately, this can cause us to run additional queries,
- // which may result in another fingerprint mismatch while we're in the middle
- // of processing this one. To avoid a double-panic (which kills the process
- // before we can print out the query static), we print out a terse
- // but 'safe' message if we detect a re-entrant call to this method.
- thread_local! {
- static INSIDE_VERIFY_PANIC: Cell<bool> = const { Cell::new(false) };
- };
+// This DebugArg business is largely a mirror of std::fmt::ArgumentV1, which is
+// currently not exposed publicly.
+//
+// The PR which added this attempted to use `&dyn Debug` instead, but that
+// showed statistically significant worse compiler performance. It's not
+// actually clear what the cause there was -- the code should be cold. If this
+// can be replaced with `&dyn Debug` with on perf impact, then it probably
+// should be.
+extern "C" {
+ type Opaque;
+}
- let old_in_panic = INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.replace(true));
+struct DebugArg<'a> {
+ value: &'a Opaque,
+ fmt: fn(&Opaque, &mut std::fmt::Formatter<'_>) -> std::fmt::Result,
+}
- if old_in_panic {
- tcx.sess().struct_err("internal compiler error: re-entrant incremental verify failure, suppressing message")
- .emit();
- } else {
- tcx.sess().struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node))
+impl<'a, T> From<&'a T> for DebugArg<'a>
+where
+ T: std::fmt::Debug,
+{
+ fn from(value: &'a T) -> DebugArg<'a> {
+ DebugArg {
+ value: unsafe { std::mem::transmute(value) },
+ fmt: unsafe {
+ std::mem::transmute(<T as std::fmt::Debug>::fmt as fn(_, _) -> std::fmt::Result)
+ },
+ }
+ }
+}
+
+impl std::fmt::Debug for DebugArg<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ (self.fmt)(self.value, f)
+ }
+}
+
+// Note that this is marked #[cold] and intentionally takes the equivalent of
+// `dyn Debug` for its arguments, as we want to avoid generating a bunch of
+// different implementations for LLVM to chew on (and filling up the final
+// binary, too).
+#[cold]
+fn incremental_verify_ich_cold(sess: &Session, dep_node: DebugArg<'_>, result: DebugArg<'_>) {
+ let run_cmd = if let Some(crate_name) = &sess.opts.crate_name {
+ format!("`cargo clean -p {}` or `cargo clean`", crate_name)
+ } else {
+ "`cargo clean`".to_string()
+ };
+
+ // When we emit an error message and panic, we try to debug-print the `DepNode`
+ // and query result. Unfortunately, this can cause us to run additional queries,
+ // which may result in another fingerprint mismatch while we're in the middle
+ // of processing this one. To avoid a double-panic (which kills the process
+ // before we can print out the query static), we print out a terse
+ // but 'safe' message if we detect a re-entrant call to this method.
+ thread_local! {
+ static INSIDE_VERIFY_PANIC: Cell<bool> = const { Cell::new(false) };
+ };
+
+ let old_in_panic = INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.replace(true));
+
+ if old_in_panic {
+ sess.struct_err(
+ "internal compiler error: re-entrant incremental verify failure, suppressing message",
+ )
+ .emit();
+ } else {
+ sess.struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node))
.help(&format!("This is a known issue with the compiler. Run {} to allow your project to compile", run_cmd))
.note(&"Please follow the instructions below to create a bug report with the provided information")
.note(&"See <https://github.com/rust-lang/rust/issues/84970> for more information")
.emit();
- panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result);
- }
-
- INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.set(old_in_panic));
+ panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result);
}
+
+ INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.set(old_in_panic));
}
/// Ensure that either this query has all green inputs or been executed.
// let foo =...
// ^^^ given this Span
// ------- get this Span to have an applicable suggestion
+
+ // edit:
+ // only do this if the const and usage of the non-constant value are on the same line
+ // the further the two are apart, the higher the chance of the suggestion being wrong
+ // also make sure that the pos for the suggestion is not 0 (ICE #90878)
+
let sp =
self.session.source_map().span_extend_to_prev_str(ident.span, current, true);
- if sp.lo().0 == 0 {
+
+ let pos_for_suggestion = sp.lo().0.saturating_sub(current.len() as u32);
+
+ if sp.lo().0 == 0
+ || pos_for_suggestion == 0
+ || self.session.source_map().is_multiline(sp)
+ {
err.span_label(ident.span, &format!("this would need to be a `{}`", sugg));
} else {
- let sp = sp.with_lo(BytePos(sp.lo().0 - current.len() as u32));
+ let sp = sp.with_lo(BytePos(pos_for_suggestion));
err.span_suggestion(
sp,
&format!("consider using `{}` instead of `{}`", sugg, current),
let mut reexport_error = None;
let mut any_successful_reexport = false;
+ let mut crate_private_reexport = false;
self.r.per_ns(|this, ns| {
if let Ok(binding) = source_bindings[ns].get() {
let vis = import.vis.get();
if !binding.vis.is_at_least(vis, &*this) {
reexport_error = Some((ns, binding));
+ if let ty::Visibility::Restricted(binding_def_id) = binding.vis {
+ if binding_def_id.is_top_level_module() {
+ crate_private_reexport = true;
+ }
+ }
} else {
any_successful_reexport = true;
}
import.span,
&msg,
);
- } else if ns == TypeNS {
- struct_span_err!(
- self.r.session,
- import.span,
- E0365,
- "`{}` is private, and cannot be re-exported",
- ident
- )
- .span_label(import.span, format!("re-export of private `{}`", ident))
- .note(&format!("consider declaring type or module `{}` with `pub`", ident))
- .emit();
} else {
- let msg = format!("`{}` is private, and cannot be re-exported", ident);
- let note_msg =
- format!("consider marking `{}` as `pub` in the imported module", ident,);
- struct_span_err!(self.r.session, import.span, E0364, "{}", &msg)
- .span_note(import.span, ¬e_msg)
- .emit();
+ let error_msg = if crate_private_reexport {
+ format!(
+ "`{}` is only public within the crate, and cannot be re-exported outside",
+ ident
+ )
+ } else {
+ format!("`{}` is private, and cannot be re-exported", ident)
+ };
+
+ if ns == TypeNS {
+ let label_msg = if crate_private_reexport {
+ format!("re-export of crate public `{}`", ident)
+ } else {
+ format!("re-export of private `{}`", ident)
+ };
+
+ struct_span_err!(self.r.session, import.span, E0365, "{}", error_msg)
+ .span_label(import.span, label_msg)
+ .note(&format!("consider declaring type or module `{}` with `pub`", ident))
+ .emit();
+ } else {
+ let note_msg =
+ format!("consider marking `{}` as `pub` in the imported module", ident);
+ struct_span_err!(self.r.session, import.span, E0364, "{}", error_msg)
+ .span_note(import.span, ¬e_msg)
+ .emit();
+ }
}
}
let (span, sugg) = if let Some(param) = generics.params.iter().find(|p| {
!matches!(
p.kind,
- hir::GenericParamKind::Type {
- synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
- ..
- } | hir::GenericParamKind::Lifetime {
- kind: hir::LifetimeParamKind::Elided,
- }
+ hir::GenericParamKind::Type { synthetic: true, .. }
+ | hir::GenericParamKind::Lifetime {
+ kind: hir::LifetimeParamKind::Elided,
+ }
)
}) {
(param.span.shrink_to_lo(), format!("{}, ", lifetime_ref))
if let Some(param) = generics.params.iter().find(|p| {
!matches!(
p.kind,
- hir::GenericParamKind::Type {
- synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
- ..
- } | hir::GenericParamKind::Lifetime {
- kind: hir::LifetimeParamKind::Elided
- }
+ hir::GenericParamKind::Type { synthetic: true, .. }
+ | hir::GenericParamKind::Lifetime {
+ kind: hir::LifetimeParamKind::Elided
+ }
)
}) {
(param.span.shrink_to_lo(), "'a, ".to_string())
feature,
reason,
issue,
+ None,
is_soft,
span,
soft_handler,
}
}
+ fn emit_fieldless_enum_variant<const ID: usize>(
+ &mut self,
+ name: &str,
+ ) -> Result<(), Self::Error> {
+ escape_str(self.writer, name)
+ }
+
fn emit_enum_variant_arg<F>(&mut self, first: bool, f: F) -> EncodeResult
where
F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
}
}
+ fn emit_fieldless_enum_variant<const ID: usize>(
+ &mut self,
+ name: &str,
+ ) -> Result<(), Self::Error> {
+ escape_str(self.writer, name)
+ }
+
fn emit_enum_variant_arg<F>(&mut self, first: bool, f: F) -> EncodeResult
where
F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
f(self)
}
+ // We put the field index in a const generic to allow the emit_usize to be
+ // compiled into a more efficient form. In practice, the variant index is
+ // known at compile-time, and that knowledge allows much more efficient
+ // codegen than we'd otherwise get. LLVM isn't always able to make the
+ // optimization that would otherwise be necessary here, likely due to the
+ // multiple levels of inlining and const-prop that are needed.
+ #[inline]
+ fn emit_fieldless_enum_variant<const ID: usize>(
+ &mut self,
+ _v_name: &str,
+ ) -> Result<(), Self::Error> {
+ self.emit_usize(ID)
+ }
+
#[inline]
fn emit_enum_variant_arg<F>(&mut self, _first: bool, f: F) -> Result<(), Self::Error>
where
Disabled,
}
+/// Used with `-Z assert-incr-state`.
+#[derive(Clone, Copy, PartialEq, Hash, Debug)]
+pub enum IncrementalStateAssertion {
+ /// Found and loaded an existing session directory.
+ ///
+ /// Note that this says nothing about whether any particular query
+ /// will be found to be red or green.
+ Loaded,
+ /// Did not load an existing session directory.
+ NotLoaded,
+}
+
impl LinkerPluginLto {
pub fn enabled(&self) -> bool {
match *self {
}
/// Parameter to control path trimming.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum TrimmedDefPaths {
/// `try_print_trimmed_def_path` never prints a trimmed path and never calls the expensive query
+ #[default]
Never,
/// `try_print_trimmed_def_path` calls the expensive query, the query doesn't call `delay_good_path_bug`
Always,
GoodPath,
}
-impl Default for TrimmedDefPaths {
- fn default() -> Self {
- Self::Never
- }
-}
-
/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
/// dependency tracking for command-line arguments. Also only hash keys, since tracking
TlsModels,
TargetSpec,
NativeStaticLibs,
+ StackProtectorStrategies,
}
#[derive(Copy, Clone)]
impl Default for Options {
fn default() -> Options {
Options {
+ assert_incr_state: None,
crate_types: Vec::new(),
optimize: OptLevel::No,
debuginfo: DebugInfo::None,
"print",
"Compiler information to print on stdout",
"[crate-name|file-names|sysroot|target-libdir|cfg|target-list|\
- target-cpus|target-features|relocation-models|\
- code-models|tls-models|target-spec-json|native-static-libs]",
+ target-cpus|target-features|relocation-models|code-models|\
+ tls-models|target-spec-json|native-static-libs|stack-protector-strategies]",
),
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
"code-models" => PrintRequest::CodeModels,
"tls-models" => PrintRequest::TlsModels,
"native-static-libs" => PrintRequest::NativeStaticLibs,
+ "stack-protector-strategies" => PrintRequest::StackProtectorStrategies,
"target-spec-json" => {
if dopts.unstable_options {
PrintRequest::TargetSpec
}
}
+crate fn parse_assert_incr_state(
+ opt_assertion: &Option<String>,
+ error_format: ErrorOutputType,
+) -> Option<IncrementalStateAssertion> {
+ match opt_assertion {
+ Some(s) if s.as_str() == "loaded" => Some(IncrementalStateAssertion::Loaded),
+ Some(s) if s.as_str() == "not-loaded" => Some(IncrementalStateAssertion::NotLoaded),
+ Some(s) => early_error(
+ error_format,
+ &format!("unexpected incremental state assertion value: {}", s),
+ ),
+ None => None,
+ }
+}
+
fn parse_native_lib_kind(
matches: &getopts::Matches,
kind: &str,
let incremental = cg.incremental.as_ref().map(PathBuf::from);
+ let assert_incr_state =
+ parse_assert_incr_state(&debugging_opts.assert_incr_state, error_format);
+
if debugging_opts.profile && incremental.is_some() {
early_error(
error_format,
};
Options {
+ assert_incr_state,
crate_types,
optimize: opt_level,
debuginfo,
use rustc_span::edition::Edition;
use rustc_span::RealFileName;
use rustc_target::spec::{CodeModel, MergeFunctions, PanicStrategy, RelocModel};
- use rustc_target::spec::{RelroLevel, SanitizerSet, SplitDebuginfo, TargetTriple, TlsModel};
+ use rustc_target::spec::{
+ RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
+ };
use std::collections::hash_map::DefaultHasher;
use std::collections::BTreeMap;
use std::hash::Hash;
Edition,
LinkerPluginLto,
SplitDebuginfo,
+ StackProtector,
SwitchWithOptPath,
SymbolManglingVersion,
SourceFileHashAlgorithm,
#![feature(crate_visibility_modifier)]
+#![feature(derive_default_enum)]
#![feature(min_specialization)]
#![feature(once_cell)]
#![recursion_limit = "256"]
use crate::lint;
use crate::search_paths::SearchPath;
use crate::utils::NativeLib;
-
use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy, SanitizerSet};
-use rustc_target::spec::{RelocModel, RelroLevel, SplitDebuginfo, TargetTriple, TlsModel};
+use rustc_target::spec::{
+ RelocModel, RelroLevel, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
+};
use rustc_feature::UnstableFeatures;
use rustc_span::edition::Edition;
/// If `Some`, enable incremental compilation, using the given
/// directory to store intermediate results.
incremental: Option<PathBuf> [UNTRACKED],
+ assert_incr_state: Option<IncrementalStateAssertion> [UNTRACKED],
debugging_opts: DebuggingOptions [SUBSTRUCT],
prints: Vec<PrintRequest> [UNTRACKED],
pub const parse_split_debuginfo: &str =
"one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
pub const parse_gcc_ld: &str = "one of: no value, `lld`";
+ pub const parse_stack_protector: &str =
+ "one of (`none` (default), `basic`, `strong`, or `all`)";
}
mod parse {
}
true
}
+
+ crate fn parse_stack_protector(slot: &mut StackProtector, v: Option<&str>) -> bool {
+ match v.and_then(|s| StackProtector::from_str(s).ok()) {
+ Some(ssp) => *slot = ssp,
+ _ => return false,
+ }
+ true
+ }
}
options! {
"make cfg(version) treat the current version as incomplete (default: no)"),
asm_comments: bool = (false, parse_bool, [TRACKED],
"generate comments into the assembly (may change behavior) (default: no)"),
+ assert_incr_state: Option<String> = (None, parse_opt_string, [UNTRACKED],
+ "assert that the incremental cache is in given state: \
+ either `loaded` or `not-loaded`."),
ast_json: bool = (false, parse_bool, [UNTRACKED],
"print the AST as JSON and halt (default: no)"),
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
and set the maximum total size of a const allocation for which this is allowed (default: never)"),
perf_stats: bool = (false, parse_bool, [UNTRACKED],
"print some performance-related statistics (default: no)"),
+ pick_stable_methods_before_any_unstable: bool = (true, parse_bool, [TRACKED],
+ "try to pick stable methods first before picking any unstable methods (default: yes)"),
plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
"whether to use the PLT when calling into shared libraries;
only has effect for PIC code on systems with ELF binaries
"exclude spans when debug-printing compiler state (default: no)"),
src_hash_algorithm: Option<SourceFileHashAlgorithm> = (None, parse_src_file_hash, [TRACKED],
"hash algorithm of source files in debug info (`md5`, `sha1`, or `sha256`)"),
+ stack_protector: StackProtector = (StackProtector::None, parse_stack_protector, [TRACKED],
+ "control stack smash protection strategy (`rustc --print stack-protector-strategies` for details)"),
strip: Strip = (Strip::None, parse_strip, [UNTRACKED],
"tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"),
split_dwarf_inlining: bool = (true, parse_bool, [UNTRACKED],
use rustc_span::{sym, SourceFileHashAlgorithm, Symbol};
use rustc_target::asm::InlineAsmArch;
use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
-use rustc_target::spec::{SanitizerSet, SplitDebuginfo, Target, TargetTriple, TlsModel};
+use rustc_target::spec::{
+ SanitizerSet, SplitDebuginfo, StackProtector, Target, TargetTriple, TlsModel,
+};
use std::cell::{self, RefCell};
use std::env;
self.opts.cg.split_debuginfo.unwrap_or(self.target.split_debuginfo)
}
+ pub fn stack_protector(&self) -> StackProtector {
+ if self.target.options.supports_stack_protector {
+ self.opts.debugging_opts.stack_protector
+ } else {
+ StackProtector::None
+ }
+ }
+
pub fn target_can_use_split_dwarf(&self) -> bool {
!self.target.is_like_windows && !self.target.is_like_osx
}
sess.err("`-Zsanitizer=cfi` requires `-Clto`");
}
}
+
+ if sess.opts.debugging_opts.stack_protector != StackProtector::None {
+ if !sess.target.options.supports_stack_protector {
+ sess.warn(&format!(
+ "`-Z stack-protector={}` is not supported for target {} and will be ignored",
+ sess.opts.debugging_opts.stack_protector, sess.opts.target_triple
+ ))
+ }
+ }
}
/// Holds data on the current incremental compilation session, if there is one.
OpaqueTy,
Async,
Await,
- ForLoop(ForLoopLoc),
+ ForLoop,
LetElse,
WhileLoop,
}
-/// A location in the desugaring of a `for` loop
-#[derive(Clone, Copy, PartialEq, Debug, Encodable, Decodable, HashStable_Generic)]
-pub enum ForLoopLoc {
- Head,
- IntoIter,
-}
-
impl DesugaringKind {
/// The description wording should combine well with "desugaring of {}".
pub fn descr(self) -> &'static str {
DesugaringKind::QuestionMark => "operator `?`",
DesugaringKind::TryBlock => "`try` block",
DesugaringKind::OpaqueTy => "`impl Trait`",
- DesugaringKind::ForLoop(_) => "`for` loop",
+ DesugaringKind::ForLoop => "`for` loop",
DesugaringKind::LetElse => "`let...else`",
DesugaringKind::WhileLoop => "`while` loop",
}
use edition::Edition;
pub mod hygiene;
use hygiene::Transparency;
-pub use hygiene::{DesugaringKind, ExpnKind, ForLoopLoc, MacroKind};
+pub use hygiene::{DesugaringKind, ExpnKind, MacroKind};
pub use hygiene::{ExpnData, ExpnHash, ExpnId, LocalExpnId, SyntaxContext};
pub mod def_id;
use def_id::{CrateNum, DefId, DefPathHash, LocalDefId, LOCAL_CRATE};
#[derive(Debug)]
pub struct SourceFileAndLine {
pub sf: Lrc<SourceFile>,
+ /// Index of line, starting from 0.
pub line: usize,
}
#[derive(Debug)]
}
pub fn span_to_margin(&self, sp: Span) -> Option<usize> {
- match self.span_to_prev_source(sp) {
- Err(_) => None,
- Ok(source) => {
- let last_line = source.rsplit_once('\n').unwrap_or(("", &source)).1;
+ Some(self.indentation_before(sp)?.len())
+ }
- Some(last_line.len() - last_line.trim_start().len())
- }
- }
+ pub fn indentation_before(&self, sp: Span) -> Option<String> {
+ self.span_to_source(sp, |src, start_index, _| {
+ let before = &src[..start_index];
+ let last_line = before.rsplit_once('\n').map_or(before, |(_, last)| last);
+ Ok(last_line
+ .split_once(|c: char| !c.is_whitespace())
+ .map_or(last_line, |(indent, _)| indent)
+ .to_string())
+ })
+ .ok()
}
/// Returns the source snippet as `String` before the given `Span`.
__D,
__H,
__S,
- __next,
__try_var,
_args,
_d,
alloc_layout,
alloc_zeroed,
allocator,
+ allocator_api,
allocator_internals,
allow,
allow_fail,
inlateout,
inline,
inline_const,
+ inline_const_pat,
inout,
instruction_set,
intel,
rustc_std_internal_symbol,
rustc_strict_coherence,
rustc_symbol_name,
- rustc_synthetic,
rustc_test_marker,
rustc_then_this_would_need,
rustc_trivial_field_reads,
}
}
+/// Controls use of stack canaries.
+#[derive(Clone, Copy, Debug, PartialEq, Hash, Eq)]
+pub enum StackProtector {
+ /// Disable stack canary generation.
+ None,
+
+ /// On LLVM, mark all generated LLVM functions with the `ssp` attribute (see
+ /// llvm/docs/LangRef.rst). This triggers stack canary generation in
+ /// functions which contain an array of a byte-sized type with more than
+ /// eight elements.
+ Basic,
+
+ /// On LLVM, mark all generated LLVM functions with the `sspstrong`
+ /// attribute (see llvm/docs/LangRef.rst). This triggers stack canary
+ /// generation in functions which either contain an array, or which take
+ /// the address of a local variable.
+ Strong,
+
+ /// Generate stack canaries in all functions.
+ All,
+}
+
+impl StackProtector {
+ fn as_str(&self) -> &'static str {
+ match self {
+ StackProtector::None => "none",
+ StackProtector::Basic => "basic",
+ StackProtector::Strong => "strong",
+ StackProtector::All => "all",
+ }
+ }
+}
+
+impl FromStr for StackProtector {
+ type Err = ();
+
+ fn from_str(s: &str) -> Result<StackProtector, ()> {
+ Ok(match s {
+ "none" => StackProtector::None,
+ "basic" => StackProtector::Basic,
+ "strong" => StackProtector::Strong,
+ "all" => StackProtector::All,
+ _ => return Err(()),
+ })
+ }
+}
+
+impl fmt::Display for StackProtector {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str(self.as_str())
+ }
+}
+
macro_rules! supported_targets {
( $(($( $triple:literal, )+ $module:ident ),)+ ) => {
$(mod $module;)+
/// Whether or not the DWARF `.debug_aranges` section should be generated.
pub generate_arange_section: bool,
+
+ /// Whether the target supports stack canary checks. `true` by default,
+ /// since this is most common among tier 1 and tier 2 targets.
+ pub supports_stack_protector: bool,
}
impl Default for TargetOptions {
default_adjusted_cabi: None,
c_enum_min_bits: 32,
generate_arange_section: true,
+ supports_stack_protector: true,
}
}
}
key!(default_adjusted_cabi, Option<Abi>)?;
key!(c_enum_min_bits, u64);
key!(generate_arange_section, bool);
+ key!(supports_stack_protector, bool);
if base.is_builtin {
// This can cause unfortunate ICEs later down the line.
target_option_val!(supported_sanitizers);
target_option_val!(c_enum_min_bits);
target_option_val!(generate_arange_section);
+ target_option_val!(supports_stack_protector);
if let Some(abi) = self.default_adjusted_cabi {
d.insert("default-adjusted-cabi".to_string(), Abi::name(abi).to_json());
// produce kernel functions that call other kernel functions.
// This behavior is not supported by PTX ISA.
merge_functions: MergeFunctions::Disabled,
+
+ // The LLVM backend does not support stack canaries for this target
+ supports_stack_protector: false,
+
..Default::default()
},
}
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(drain_filter)]
+#![feature(derive_default_enum)]
#![feature(hash_drain_filter)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
use rustc_session::Limit;
use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
-use rustc_span::{BytePos, DesugaringKind, ExpnKind, ForLoopLoc, MultiSpan, Span, DUMMY_SP};
+use rustc_span::{BytePos, DesugaringKind, ExpnKind, MultiSpan, Span, DUMMY_SP};
use rustc_target::spec::abi;
use std::fmt;
} else {
// Trivial case: `T` needs an extra bound: `T: Bound`.
let (sp, suggestion) = match (
- generics.params.iter().find(|p| {
- !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), .. })
- }),
+ generics
+ .params
+ .iter()
+ .find(|p| !matches!(p.kind, hir::GenericParamKind::Type { synthetic: true, .. })),
super_traits,
) {
(_, None) => predicate_constraint(
&obligation.cause.code
{
parent_code.clone()
- } else if let ExpnKind::Desugaring(DesugaringKind::ForLoop(ForLoopLoc::IntoIter)) =
+ } else if let ExpnKind::Desugaring(DesugaringKind::ForLoop) =
span.ctxt().outer_expn_data().kind
{
Lrc::new(obligation.cause.code.clone())
// This if is to prevent a special edge-case
if matches!(
span.ctxt().outer_expn_data().kind,
- ExpnKind::Root
- | ExpnKind::Desugaring(DesugaringKind::ForLoop(ForLoopLoc::IntoIter))
+ ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop)
) {
// We don't want a borrowing suggestion on the fields in structs,
// ```
region, object_ty,
));
}
- ObligationCauseCode::ItemObligation(item_def_id) => {
- let item_name = tcx.def_path_str(item_def_id);
- let msg = format!("required by `{}`", item_name);
- let sp = tcx
- .hir()
- .span_if_local(item_def_id)
- .unwrap_or_else(|| tcx.def_span(item_def_id));
- let sp = tcx.sess.source_map().guess_head_span(sp);
- err.span_note(sp, &msg);
+ ObligationCauseCode::ItemObligation(_item_def_id) => {
+ // We hold the `DefId` of the item introducing the obligation, but displaying it
+ // doesn't add user usable information. It always point at an associated item.
}
ObligationCauseCode::BindingObligation(item_def_id, span) => {
let item_name = tcx.def_path_str(item_def_id);
pub use rustc_infer::traits::*;
/// Whether to skip the leak check, as part of a future compatibility warning step.
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+///
+/// The "default" for skip-leak-check corresponds to the current
+/// behavior (do not skip the leak check) -- not the behavior we are
+/// transitioning into.
+#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
pub enum SkipLeakCheck {
Yes,
+ #[default]
No,
}
}
}
-/// The "default" for skip-leak-check corresponds to the current
-/// behavior (do not skip the leak check) -- not the behavior we are
-/// transitioning into.
-impl Default for SkipLeakCheck {
- fn default() -> Self {
- SkipLeakCheck::No
- }
-}
-
/// The mode that trait queries run in.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum TraitQueryMode {
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
use super::{Normalized, Obligation, ObligationCause, PredicateObligation, SelectionContext};
-pub use rustc_infer::traits::util::*;
+pub use rustc_infer::traits::{self, util::*};
+
+use std::iter;
///////////////////////////////////////////////////////////////////////////
// `TraitAliasExpander` iterator
) -> impl Iterator<Item = PredicateObligation<'tcx>> {
debug!("predicates_for_generics(generic_bounds={:?})", generic_bounds);
- generic_bounds.predicates.into_iter().map(move |predicate| Obligation {
- cause: cause.clone(),
- recursion_depth,
- param_env,
- predicate,
+ iter::zip(generic_bounds.predicates, generic_bounds.spans).map(move |(predicate, span)| {
+ let cause = match cause.code {
+ traits::ItemObligation(def_id) if !span.is_dummy() => traits::ObligationCause::new(
+ cause.span,
+ cause.body_id,
+ traits::BindingObligation(def_id, span),
+ ),
+ _ => cause.clone(),
+ };
+ Obligation { cause, recursion_depth, param_env, predicate }
})
}
iter::zip(iter::zip(predicates.predicates, predicates.spans), origins.into_iter().rev())
.map(|((pred, span), origin_def_id)| {
- let cause = self.cause(traits::BindingObligation(origin_def_id, span));
+ let code = if span.is_dummy() {
+ traits::MiscObligation
+ } else {
+ traits::BindingObligation(origin_def_id, span)
+ };
+ let cause = self.cause(code);
traits::Obligation::with_depth(cause, self.recursion_depth, self.param_env, pred)
})
.filter(|pred| !pred.has_escaping_bound_vars())
.params
.iter()
.filter(|param| {
- matches!(
- param.kind,
- ty::GenericParamDefKind::Type {
- synthetic: Some(
- hir::SyntheticTyParamKind::ImplTrait
- | hir::SyntheticTyParamKind::FromAttr
- ),
- ..
- }
- )
+ matches!(param.kind, ty::GenericParamDefKind::Type { synthetic: true, .. })
})
.count()
} else {
ty::FnPtr(sig) => (sig, None),
ref t => {
let mut unit_variant = None;
+ let mut removal_span = call_expr.span;
if let ty::Adt(adt_def, ..) = t {
if adt_def.is_enum() {
if let hir::ExprKind::Call(expr, _) = call_expr.kind {
+ removal_span =
+ expr.span.shrink_to_hi().to(call_expr.span.shrink_to_hi());
unit_variant =
self.tcx.sess.source_map().span_to_snippet(expr.span).ok();
}
);
if let Some(ref path) = unit_variant {
- err.span_suggestion(
- call_expr.span,
+ err.span_suggestion_verbose(
+ removal_span,
&format!(
- "`{}` is a unit variant, you need to write it \
- without the parentheses",
+ "`{}` is a unit variant, you need to write it without the parentheses",
path
),
- path.to_string(),
+ String::new(),
Applicability::MachineApplicable,
);
}
let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_hir_id);
let param_env =
ty::ParamEnv::new(tcx.intern_predicates(&hybrid_preds.predicates), Reveal::UserFacing);
- let param_env = traits::normalize_param_env_or_error(
- tcx,
- impl_m.def_id,
- param_env,
- normalize_cause.clone(),
- );
+ let param_env =
+ traits::normalize_param_env_or_error(tcx, impl_m.def_id, param_env, normalize_cause);
tcx.infer_ctxt().enter(|infcx| {
let inh = Inherited::new(infcx, impl_m.def_id.expect_local());
let mut selcx = traits::SelectionContext::new(&infcx);
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_placeholder_substs);
- for predicate in impl_m_own_bounds.predicates {
+ for (predicate, span) in iter::zip(impl_m_own_bounds.predicates, impl_m_own_bounds.spans) {
+ let normalize_cause = traits::ObligationCause::misc(span, impl_m_hir_id);
let traits::Normalized { value: predicate, obligations } =
- traits::normalize(&mut selcx, param_env, normalize_cause.clone(), predicate);
+ traits::normalize(&mut selcx, param_env, normalize_cause, predicate);
inh.register_predicates(obligations);
- inh.register_predicate(traits::Obligation::new(cause.clone(), param_env, predicate));
+ let mut cause = cause.clone();
+ cause.make_mut().span = span;
+ inh.register_predicate(traits::Obligation::new(cause, param_env, predicate));
}
// We now need to check that the signature of the impl method is
let sub_result = infcx.at(&cause, param_env).sup(trait_fty, impl_fty).map(
|InferOk { obligations, .. }| {
+ // FIXME: We'd want to keep more accurate spans than "the method signature" when
+ // processing the comparison between the trait and impl fn, but we sadly lose them
+ // and point at the whole signature when a trait bound or specific input or output
+ // type would be more appropriate. In other places we have a `Vec<Span>`
+ // corresponding to their `Vec<Predicate>`, but we don't have that here.
+ // Fixing this would improve the output of test `issue-83765.rs`.
inh.register_predicates(obligations);
},
);
.params
.iter()
.filter_map(|p| match p.kind {
- GenericParamKind::Type {
- synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
- ..
- } => Some(p.span),
+ GenericParamKind::Type { synthetic: true, .. } => Some(p.span),
_ => None,
})
.collect();
.params
.iter()
.filter_map(|p| match p.kind {
- GenericParamKind::Type {
- synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
- ..
- } => Some(p.span),
+ GenericParamKind::Type { synthetic: true, .. } => Some(p.span),
_ => None,
})
.collect();
match (impl_synthetic, trait_synthetic) {
// The case where the impl method uses `impl Trait` but the trait method uses
// explicit generics
- (Some(hir::SyntheticTyParamKind::ImplTrait), None) => {
+ (true, false) => {
err.span_label(impl_span, "expected generic parameter, found `impl Trait`");
(|| {
// try taking the name from the trait impl
}
// The case where the trait method uses `impl Trait`, but the impl method uses
// explicit generics.
- (None, Some(hir::SyntheticTyParamKind::ImplTrait)) => {
+ (false, true) => {
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
(|| {
let impl_m = impl_m.def_id.as_local()?;
let impl_ty_hir_id = tcx.hir().local_def_id_to_hir_id(impl_ty.def_id.expect_local());
let normalize_cause = traits::ObligationCause::misc(impl_ty_span, impl_ty_hir_id);
- let mk_cause = |span| {
- ObligationCause::new(
- impl_ty_span,
- impl_ty_hir_id,
- ObligationCauseCode::BindingObligation(trait_ty.def_id, span),
- )
+ let mk_cause = |span: Span| {
+ let code = if span.is_dummy() {
+ traits::MiscObligation
+ } else {
+ traits::BindingObligation(trait_ty.def_id, span)
+ };
+ ObligationCause::new(impl_ty_span, impl_ty_hir_id, code)
};
let obligations = tcx
return;
}
- let mut compatible_variants = expected_adt
+ // If the expression is of type () and it's the return expression of a block,
+ // we suggest adding a separate return expression instead.
+ // (To avoid things like suggesting `Ok(while .. { .. })`.)
+ if expr_ty.is_unit() {
+ if let Some(hir::Node::Block(&hir::Block {
+ span: block_span, expr: Some(e), ..
+ })) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id))
+ {
+ if e.hir_id == expr.hir_id {
+ if let Some(span) = expr.span.find_ancestor_inside(block_span) {
+ let return_suggestions =
+ if self.tcx.is_diagnostic_item(sym::Result, expected_adt.did) {
+ vec!["Ok(())".to_string()]
+ } else if self.tcx.is_diagnostic_item(sym::Option, expected_adt.did)
+ {
+ vec!["None".to_string(), "Some(())".to_string()]
+ } else {
+ return;
+ };
+ if let Some(indent) =
+ self.tcx.sess.source_map().indentation_before(span.shrink_to_lo())
+ {
+ // Add a semicolon, except after `}`.
+ let semicolon =
+ match self.tcx.sess.source_map().span_to_snippet(span) {
+ Ok(s) if s.ends_with('}') => "",
+ _ => ";",
+ };
+ err.span_suggestions(
+ span.shrink_to_hi(),
+ "try adding an expression at the end of the block",
+ return_suggestions
+ .into_iter()
+ .map(|r| format!("{}\n{}{}", semicolon, indent, r)),
+ Applicability::MaybeIncorrect,
+ );
+ }
+ return;
+ }
+ }
+ }
+ }
+
+ let compatible_variants: Vec<String> = expected_adt
.variants
.iter()
.filter(|variant| variant.fields.len() == 1)
None
}
})
- .peekable();
+ .collect();
- if compatible_variants.peek().is_some() {
- if let Ok(expr_text) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
- let suggestions = compatible_variants.map(|v| format!("{}({})", v, expr_text));
- let msg = "try using a variant of the expected enum";
- err.span_suggestions(
- expr.span,
- msg,
- suggestions,
- Applicability::MaybeIncorrect,
- );
- }
+ if let [variant] = &compatible_variants[..] {
+ // Just a single matching variant.
+ err.multipart_suggestion(
+ &format!("try wrapping the expression in `{}`", variant),
+ vec![
+ (expr.span.shrink_to_lo(), format!("{}(", variant)),
+ (expr.span.shrink_to_hi(), ")".to_string()),
+ ],
+ Applicability::MaybeIncorrect,
+ );
+ } else if compatible_variants.len() > 1 {
+ // More than one matching variant.
+ err.multipart_suggestions(
+ &format!(
+ "try wrapping the expression in a variant of `{}`",
+ self.tcx.def_path_str(expected_adt.did)
+ ),
+ compatible_variants.into_iter().map(|variant| {
+ vec![
+ (expr.span.shrink_to_lo(), format!("{}(", variant)),
+ (expr.span.shrink_to_hi(), ")".to_string()),
+ ]
+ }),
+ Applicability::MaybeIncorrect,
+ );
}
}
}
fn point_at_param_definition(&self, err: &mut DiagnosticBuilder<'_>, param: ty::ParamTy) {
let generics = self.tcx.generics_of(self.body_id.owner.to_def_id());
let generic_param = generics.type_param(¶m, self.tcx);
- if let ty::GenericParamDefKind::Type { synthetic: Some(..), .. } = generic_param.kind {
+ if let ty::GenericParamDefKind::Type { synthetic: true, .. } = generic_param.kind {
return;
}
let param_def_id = generic_param.def_id;
}
}
- /// Given a fully substituted set of bounds (`generic_bounds`), and the values with which each
- /// type/region parameter was instantiated (`substs`), creates and registers suitable
- /// trait/region obligations.
- ///
- /// For example, if there is a function:
- ///
- /// ```
- /// fn foo<'a,T:'a>(...)
- /// ```
- ///
- /// and a reference:
- ///
- /// ```
- /// let f = foo;
- /// ```
- ///
- /// Then we will create a fresh region variable `'$0` and a fresh type variable `$1` for `'a`
- /// and `T`. This routine will add a region obligation `$1:'$0` and register it locally.
- pub fn add_obligations_for_parameters(
- &self,
- cause: traits::ObligationCause<'tcx>,
- predicates: ty::InstantiatedPredicates<'tcx>,
- ) {
- assert!(!predicates.has_escaping_bound_vars());
-
- debug!("add_obligations_for_parameters(predicates={:?})", predicates);
-
- for obligation in traits::predicates_for_generics(cause, self.param_env, predicates) {
- self.register_predicate(obligation);
- }
- }
-
// FIXME(arielb1): use this instead of field.ty everywhere
// Only for fields! Returns <none> for methods>
// Indifferent to privacy flags
/// Add all the obligations that are required, substituting and normalized appropriately.
#[tracing::instrument(level = "debug", skip(self, span, def_id, substs))]
- fn add_required_obligations(&self, span: Span, def_id: DefId, substs: &SubstsRef<'tcx>) {
- let (bounds, spans) = self.instantiate_bounds(span, def_id, &substs);
+ crate fn add_required_obligations(&self, span: Span, def_id: DefId, substs: &SubstsRef<'tcx>) {
+ let (bounds, _) = self.instantiate_bounds(span, def_id, &substs);
- for (i, mut obligation) in traits::predicates_for_generics(
+ for obligation in traits::predicates_for_generics(
traits::ObligationCause::new(span, self.body_id, traits::ItemObligation(def_id)),
self.param_env,
bounds,
- )
- .enumerate()
- {
- // This makes the error point at the bound, but we want to point at the argument
- if let Some(span) = spans.get(i) {
- obligation.cause.make_mut().code = traits::BindingObligation(def_id, *span);
- }
+ ) {
self.register_predicate(obligation);
}
}
self.write_user_type_annotation_from_substs(hir_id, did, substs, None);
// Check bounds on type arguments used in the path.
- let (bounds, _) = self.instantiate_bounds(path_span, did, substs);
- let cause =
- traits::ObligationCause::new(path_span, self.body_id, traits::ItemObligation(did));
- self.add_obligations_for_parameters(cause, bounds);
+ self.add_required_obligations(path_span, did, substs);
Some((variant, ty))
} else {
// We won't add these if we encountered an illegal sized bound, so that we can use
// a custom error in that case.
if illegal_sized_bound.is_none() {
- self.add_obligations(self.tcx.mk_fn_ptr(method_sig), all_substs, method_predicates);
+ self.add_obligations(
+ self.tcx.mk_fn_ptr(method_sig),
+ all_substs,
+ method_predicates,
+ pick.item.def_id,
+ );
}
// Create the final `MethodCallee`.
fty: Ty<'tcx>,
all_substs: SubstsRef<'tcx>,
method_predicates: ty::InstantiatedPredicates<'tcx>,
+ def_id: DefId,
) {
debug!(
- "add_obligations: fty={:?} all_substs={:?} method_predicates={:?}",
- fty, all_substs, method_predicates
+ "add_obligations: fty={:?} all_substs={:?} method_predicates={:?} def_id={:?}",
+ fty, all_substs, method_predicates, def_id
);
- self.add_obligations_for_parameters(
- traits::ObligationCause::misc(self.span, self.body_id),
+ // FIXME: could replace with the following, but we already calculated `method_predicates`,
+ // so we just call `predicates_for_generics` directly to avoid redoing work.
+ // `self.add_required_obligations(self.span, def_id, &all_substs);`
+ for obligation in traits::predicates_for_generics(
+ traits::ObligationCause::new(self.span, self.body_id, traits::ItemObligation(def_id)),
+ self.param_env,
method_predicates,
- );
+ ) {
+ self.register_predicate(obligation);
+ }
// this is a projection from a trait reference, so we have to
// make sure that the trait reference inputs are well-formed.
pub use self::MethodError::*;
use crate::check::FnCtxt;
+use crate::ObligationCause;
use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir;
#[derive(Debug)]
pub struct NoMatchData<'tcx> {
pub static_candidates: Vec<CandidateSource>,
- pub unsatisfied_predicates: Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)>,
+ pub unsatisfied_predicates:
+ Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>, Option<ObligationCause<'tcx>>)>,
pub out_of_scope_traits: Vec<DefId>,
pub lev_candidate: Option<ty::AssocItem>,
pub mode: probe::Mode,
impl<'tcx> NoMatchData<'tcx> {
pub fn new(
static_candidates: Vec<CandidateSource>,
- unsatisfied_predicates: Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)>,
+ unsatisfied_predicates: Vec<(
+ ty::Predicate<'tcx>,
+ Option<ty::Predicate<'tcx>>,
+ Option<ObligationCause<'tcx>>,
+ )>,
out_of_scope_traits: Vec<DefId>,
lev_candidate: Option<ty::AssocItem>,
mode: probe::Mode,
/// Collects near misses when trait bounds for type parameters are unsatisfied and is only used
/// for error reporting
- unsatisfied_predicates: Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)>,
+ unsatisfied_predicates:
+ Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>, Option<ObligationCause<'tcx>>)>,
is_suggestion: IsSuggestion,
}
}
-#[derive(Debug)]
+#[derive(Debug, Clone)]
struct Candidate<'tcx> {
// Candidates are (I'm not quite sure, but they are mostly) basically
// some metadata on top of a `ty::AssocItem` (without substs).
import_ids: SmallVec<[LocalDefId; 1]>,
}
-#[derive(Debug)]
+#[derive(Debug, Clone)]
enum CandidateKind<'tcx> {
InherentImplCandidate(
SubstsRef<'tcx>,
/// Indicates that we want to add an autoref (and maybe also unsize it), or if the receiver is
/// `*mut T`, convert it to `*const T`.
pub autoref_or_ptr_adjustment: Option<AutorefOrPtrAdjustment<'tcx>>,
+ pub self_ty: Ty<'tcx>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
}
fn pick_core(&mut self) -> Option<PickResult<'tcx>> {
- let steps = self.steps.clone();
+ let mut unstable_candidates = Vec::new();
+ let pick = self.pick_all_method(Some(&mut unstable_candidates));
+
+ // In this case unstable picking is done by `pick_method`.
+ if !self.tcx.sess.opts.debugging_opts.pick_stable_methods_before_any_unstable {
+ return pick;
+ }
- // find the first step that works
+ match pick {
+ // Emit a lint if there are unstable candidates alongside the stable ones.
+ //
+ // We suppress warning if we're picking the method only because it is a
+ // suggestion.
+ Some(Ok(ref p)) if !self.is_suggestion.0 && !unstable_candidates.is_empty() => {
+ self.emit_unstable_name_collision_hint(p, &unstable_candidates);
+ pick
+ }
+ Some(_) => pick,
+ None => self.pick_all_method(None),
+ }
+ }
+
+ fn pick_all_method(
+ &mut self,
+ mut unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>,
+ ) -> Option<PickResult<'tcx>> {
+ let steps = self.steps.clone();
steps
.iter()
.filter(|step| {
- debug!("pick_core: step={:?}", step);
+ debug!("pick_all_method: step={:?}", step);
// skip types that are from a type error or that would require dereferencing
// a raw pointer
!step.self_ty.references_error() && !step.from_unsafe_deref
.unwrap_or_else(|_| {
span_bug!(self.span, "{:?} was applicable but now isn't?", step.self_ty)
});
- self.pick_by_value_method(step, self_ty).or_else(|| {
- self.pick_autorefd_method(step, self_ty, hir::Mutability::Not)
- .or_else(|| self.pick_autorefd_method(step, self_ty, hir::Mutability::Mut))
- .or_else(|| self.pick_const_ptr_method(step, self_ty))
- })
+ self.pick_by_value_method(step, self_ty, unstable_candidates.as_deref_mut())
+ .or_else(|| {
+ self.pick_autorefd_method(
+ step,
+ self_ty,
+ hir::Mutability::Not,
+ unstable_candidates.as_deref_mut(),
+ )
+ .or_else(|| {
+ self.pick_autorefd_method(
+ step,
+ self_ty,
+ hir::Mutability::Mut,
+ unstable_candidates.as_deref_mut(),
+ )
+ })
+ .or_else(|| {
+ self.pick_const_ptr_method(
+ step,
+ self_ty,
+ unstable_candidates.as_deref_mut(),
+ )
+ })
+ })
})
.next()
}
&mut self,
step: &CandidateStep<'tcx>,
self_ty: Ty<'tcx>,
+ unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>,
) -> Option<PickResult<'tcx>> {
if step.unsize {
return None;
}
- self.pick_method(self_ty).map(|r| {
+ self.pick_method(self_ty, unstable_candidates).map(|r| {
r.map(|mut pick| {
pick.autoderefs = step.autoderefs;
step: &CandidateStep<'tcx>,
self_ty: Ty<'tcx>,
mutbl: hir::Mutability,
+ unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>,
) -> Option<PickResult<'tcx>> {
let tcx = self.tcx;
let region = tcx.lifetimes.re_erased;
let autoref_ty = tcx.mk_ref(region, ty::TypeAndMut { ty: self_ty, mutbl });
- self.pick_method(autoref_ty).map(|r| {
+ self.pick_method(autoref_ty, unstable_candidates).map(|r| {
r.map(|mut pick| {
pick.autoderefs = step.autoderefs;
pick.autoref_or_ptr_adjustment = Some(AutorefOrPtrAdjustment::Autoref {
&mut self,
step: &CandidateStep<'tcx>,
self_ty: Ty<'tcx>,
+ unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>,
) -> Option<PickResult<'tcx>> {
// Don't convert an unsized reference to ptr
if step.unsize {
let const_self_ty = ty::TypeAndMut { ty, mutbl: hir::Mutability::Not };
let const_ptr_ty = self.tcx.mk_ptr(const_self_ty);
- self.pick_method(const_ptr_ty).map(|r| {
+ self.pick_method(const_ptr_ty, unstable_candidates).map(|r| {
r.map(|mut pick| {
pick.autoderefs = step.autoderefs;
pick.autoref_or_ptr_adjustment = Some(AutorefOrPtrAdjustment::ToConstPtr);
})
}
- fn pick_method(&mut self, self_ty: Ty<'tcx>) -> Option<PickResult<'tcx>> {
- debug!("pick_method(self_ty={})", self.ty_to_string(self_ty));
+ fn pick_method_with_unstable(&mut self, self_ty: Ty<'tcx>) -> Option<PickResult<'tcx>> {
+ debug!("pick_method_with_unstable(self_ty={})", self.ty_to_string(self_ty));
let mut possibly_unsatisfied_predicates = Vec::new();
let mut unstable_candidates = Vec::new();
//
// We suppress warning if we're picking the method only because it is a
// suggestion.
- self.emit_unstable_name_collision_hint(p, &unstable_candidates, self_ty);
+ self.emit_unstable_name_collision_hint(p, &unstable_candidates);
}
}
return Some(pick);
debug!("searching unstable candidates");
let res = self.consider_candidates(
self_ty,
- unstable_candidates.into_iter().map(|(c, _)| c),
+ unstable_candidates.iter().map(|(c, _)| c),
&mut possibly_unsatisfied_predicates,
None,
);
res
}
+ fn pick_method(
+ &mut self,
+ self_ty: Ty<'tcx>,
+ mut unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>,
+ ) -> Option<PickResult<'tcx>> {
+ if !self.tcx.sess.opts.debugging_opts.pick_stable_methods_before_any_unstable {
+ return self.pick_method_with_unstable(self_ty);
+ }
+
+ debug!("pick_method(self_ty={})", self.ty_to_string(self_ty));
+
+ let mut possibly_unsatisfied_predicates = Vec::new();
+
+ for (kind, candidates) in
+ &[("inherent", &self.inherent_candidates), ("extension", &self.extension_candidates)]
+ {
+ debug!("searching {} candidates", kind);
+ let res = self.consider_candidates(
+ self_ty,
+ candidates.iter(),
+ &mut possibly_unsatisfied_predicates,
+ unstable_candidates.as_deref_mut(),
+ );
+ if let Some(pick) = res {
+ return Some(pick);
+ }
+ }
+
+ // `pick_method` may be called twice for the same self_ty if no stable methods
+ // match. Only extend once.
+ if unstable_candidates.is_some() {
+ self.unsatisfied_predicates.extend(possibly_unsatisfied_predicates);
+ }
+ None
+ }
+
fn consider_candidates<'b, ProbesIter>(
&self,
self_ty: Ty<'tcx>,
possibly_unsatisfied_predicates: &mut Vec<(
ty::Predicate<'tcx>,
Option<ty::Predicate<'tcx>>,
+ Option<ObligationCause<'tcx>>,
)>,
- unstable_candidates: Option<&mut Vec<(&'b Candidate<'tcx>, Symbol)>>,
+ unstable_candidates: Option<&mut Vec<(Candidate<'tcx>, Symbol)>>,
) -> Option<PickResult<'tcx>>
where
ProbesIter: Iterator<Item = &'b Candidate<'tcx>> + Clone,
+ 'tcx: 'b,
{
let mut applicable_candidates: Vec<_> = probes
.clone()
debug!("applicable_candidates: {:?}", applicable_candidates);
if applicable_candidates.len() > 1 {
- if let Some(pick) = self.collapse_candidates_to_trait_pick(&applicable_candidates[..]) {
+ if let Some(pick) =
+ self.collapse_candidates_to_trait_pick(self_ty, &applicable_candidates[..])
+ {
return Some(Ok(pick));
}
}
if let stability::EvalResult::Deny { feature, .. } =
self.tcx.eval_stability(p.item.def_id, None, self.span, None)
{
- uc.push((p, feature));
+ uc.push((p.clone(), feature));
return false;
}
true
applicable_candidates.pop().map(|(probe, status)| {
if status == ProbeResult::Match {
- Ok(probe.to_unadjusted_pick())
+ Ok(probe.to_unadjusted_pick(self_ty))
} else {
Err(MethodError::BadReturnType)
}
fn emit_unstable_name_collision_hint(
&self,
stable_pick: &Pick<'_>,
- unstable_candidates: &[(&Candidate<'tcx>, Symbol)],
- self_ty: Ty<'tcx>,
+ unstable_candidates: &[(Candidate<'tcx>, Symbol)],
) {
self.tcx.struct_span_lint_hir(
lint::builtin::UNSTABLE_NAME_COLLISIONS,
"use the fully qualified path to the associated const",
format!(
"<{} as {}>::{}",
- self_ty,
+ stable_pick.self_ty,
self.tcx.def_path_str(def_id),
stable_pick.item.ident
),
possibly_unsatisfied_predicates: &mut Vec<(
ty::Predicate<'tcx>,
Option<ty::Predicate<'tcx>>,
+ Option<ObligationCause<'tcx>>,
)>,
) -> ProbeResult {
debug!("consider_probe: self_ty={:?} probe={:?}", self_ty, probe);
.sup(probe.xform_self_ty, self_ty)
{
Ok(InferOk { obligations, value: () }) => obligations,
- Err(_) => {
- debug!("--> cannot relate self-types");
+ Err(err) => {
+ debug!("--> cannot relate self-types {:?}", err);
return ProbeResult::NoMatch;
}
};
let o = self.resolve_vars_if_possible(o);
if !self.predicate_may_hold(&o) {
result = ProbeResult::NoMatch;
- possibly_unsatisfied_predicates.push((o.predicate, None));
+ possibly_unsatisfied_predicates.push((
+ o.predicate,
+ None,
+ Some(o.cause),
+ ));
}
}
}
} else {
Some(predicate)
};
- possibly_unsatisfied_predicates
- .push((nested_predicate, p));
+ possibly_unsatisfied_predicates.push((
+ nested_predicate,
+ p,
+ Some(obligation.cause.clone()),
+ ));
}
}
}
// Some nested subobligation of this predicate
// failed.
let predicate = self.resolve_vars_if_possible(predicate);
- possibly_unsatisfied_predicates.push((predicate, None));
+ possibly_unsatisfied_predicates.push((predicate, None, None));
}
}
false
let o = self.resolve_vars_if_possible(o);
if !self.predicate_may_hold(&o) {
result = ProbeResult::NoMatch;
- possibly_unsatisfied_predicates.push((o.predicate, None));
+ possibly_unsatisfied_predicates.push((o.predicate, None, Some(o.cause)));
}
}
/// use, so it's ok to just commit to "using the method from the trait Foo".
fn collapse_candidates_to_trait_pick(
&self,
+ self_ty: Ty<'tcx>,
probes: &[(&Candidate<'tcx>, ProbeResult)],
) -> Option<Pick<'tcx>> {
// Do all probes correspond to the same trait?
import_ids: probes[0].0.import_ids.clone(),
autoderefs: 0,
autoref_or_ptr_adjustment: None,
+ self_ty,
})
}
}
impl<'tcx> Candidate<'tcx> {
- fn to_unadjusted_pick(&self) -> Pick<'tcx> {
+ fn to_unadjusted_pick(&self, self_ty: Ty<'tcx>) -> Pick<'tcx> {
Pick {
item: self.item,
kind: match self.kind {
import_ids: self.import_ids.clone(),
autoderefs: 0,
autoref_or_ptr_adjustment: None,
+ self_ty,
}
}
}
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{source_map, FileName, MultiSpan, Span, Symbol};
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
-use rustc_trait_selection::traits::{FulfillmentError, Obligation};
+use rustc_trait_selection::traits::{
+ FulfillmentError, Obligation, ObligationCause, ObligationCauseCode,
+};
use std::cmp::Ordering;
use std::iter;
.span_to_snippet(lit.span)
.unwrap_or_else(|_| "<numeric literal>".to_owned());
+ // If this is a floating point literal that ends with '.',
+ // get rid of it to stop this from becoming a member access.
+ let snippet = snippet.strip_suffix('.').unwrap_or(&snippet);
+
err.span_suggestion(
lit.span,
&format!(
like `{}`",
concrete_type
),
- format!("{}_{}", snippet, concrete_type),
+ format!("{snippet}_{concrete_type}"),
Applicability::MaybeIncorrect,
);
}
if let (ty::Param(_), ty::PredicateKind::Trait(p)) =
(self_ty.kind(), parent_pred.kind().skip_binder())
{
- if let ty::Adt(def, _) = p.trait_ref.self_ty().kind() {
- let node = def.did.as_local().map(|def_id| {
+ let node = match p.trait_ref.self_ty().kind() {
+ ty::Param(_) => {
+ // Account for `fn` items like in `issue-35677.rs` to
+ // suggest restricting its type params.
+ let did = self.tcx.hir().body_owner_def_id(hir::BodyId {
+ hir_id: self.body_id,
+ });
+ Some(
+ self.tcx
+ .hir()
+ .get(self.tcx.hir().local_def_id_to_hir_id(did)),
+ )
+ }
+ ty::Adt(def, _) => def.did.as_local().map(|def_id| {
self.tcx
.hir()
.get(self.tcx.hir().local_def_id_to_hir_id(def_id))
- });
- if let Some(hir::Node::Item(hir::Item { kind, .. })) = node {
- if let Some(g) = kind.generics() {
- let key = match g.where_clause.predicates {
- [.., pred] => (pred.span().shrink_to_hi(), false),
- [] => (
- g.where_clause
- .span_for_predicates_or_empty_place(),
- true,
- ),
- };
- type_params
- .entry(key)
- .or_insert_with(FxHashSet::default)
- .insert(obligation.to_owned());
- }
+ }),
+ _ => None,
+ };
+ if let Some(hir::Node::Item(hir::Item { kind, .. })) = node {
+ if let Some(g) = kind.generics() {
+ let key = match g.where_clause.predicates {
+ [.., pred] => (pred.span().shrink_to_hi(), false),
+ [] => (
+ g.where_clause.span_for_predicates_or_empty_place(),
+ true,
+ ),
+ };
+ type_params
+ .entry(key)
+ .or_insert_with(FxHashSet::default)
+ .insert(obligation.to_owned());
}
}
}
_ => None,
}
};
+
+ // Find all the requirements that come from a local `impl` block.
+ let mut skip_list: FxHashSet<_> = Default::default();
+ let mut spanned_predicates: FxHashMap<MultiSpan, _> = Default::default();
+ for (data, p, parent_p) in unsatisfied_predicates
+ .iter()
+ .filter_map(|(p, parent, c)| c.as_ref().map(|c| (p, parent, c)))
+ .filter_map(|(p, parent, c)| match c.code {
+ ObligationCauseCode::ImplDerivedObligation(ref data) => {
+ Some((data, p, parent))
+ }
+ _ => None,
+ })
+ {
+ let parent_trait_ref = data.parent_trait_ref;
+ let parent_def_id = parent_trait_ref.def_id();
+ let path = parent_trait_ref.print_only_trait_path();
+ let tr_self_ty = parent_trait_ref.skip_binder().self_ty();
+ let mut candidates = vec![];
+ self.tcx.for_each_relevant_impl(
+ parent_def_id,
+ parent_trait_ref.self_ty().skip_binder(),
+ |impl_def_id| match self.tcx.hir().get_if_local(impl_def_id) {
+ Some(Node::Item(hir::Item {
+ kind: hir::ItemKind::Impl(hir::Impl { .. }),
+ ..
+ })) => {
+ candidates.push(impl_def_id);
+ }
+ _ => {}
+ },
+ );
+ if let [def_id] = &candidates[..] {
+ match self.tcx.hir().get_if_local(*def_id) {
+ Some(Node::Item(hir::Item {
+ kind: hir::ItemKind::Impl(hir::Impl { of_trait, self_ty, .. }),
+ ..
+ })) => {
+ if let Some(pred) = parent_p {
+ // Done to add the "doesn't satisfy" `span_label`.
+ let _ = format_pred(*pred);
+ }
+ skip_list.insert(p);
+ let mut spans = Vec::with_capacity(2);
+ if let Some(trait_ref) = of_trait {
+ spans.push(trait_ref.path.span);
+ }
+ spans.push(self_ty.span);
+ let entry = spanned_predicates.entry(spans.into());
+ entry
+ .or_insert_with(|| (path, tr_self_ty, Vec::new()))
+ .2
+ .push(p);
+ }
+ _ => {}
+ }
+ }
+ }
+ for (span, (path, self_ty, preds)) in spanned_predicates {
+ err.span_note(
+ span,
+ &format!(
+ "the following trait bounds were not satisfied because of the \
+ requirements of the implementation of `{}` for `{}`:\n{}",
+ path,
+ self_ty,
+ preds
+ .into_iter()
+ // .map(|pred| format!("{:?}", pred))
+ .filter_map(|pred| format_pred(*pred))
+ .map(|(p, _)| format!("`{}`", p))
+ .collect::<Vec<_>>()
+ .join("\n"),
+ ),
+ );
+ }
+
+ // The requirements that didn't have an `impl` span to show.
let mut bound_list = unsatisfied_predicates
.iter()
- .filter_map(|(pred, parent_pred)| {
- format_pred(*pred).map(|(p, self_ty)| match parent_pred {
- None => format!("`{}`", &p),
- Some(parent_pred) => match format_pred(*parent_pred) {
+ .filter(|(pred, _, _parent_pred)| !skip_list.contains(&pred))
+ .filter_map(|(pred, parent_pred, _cause)| {
+ format_pred(*pred).map(|(p, self_ty)| {
+ collect_type_param_suggestions(self_ty, pred, &p);
+ match parent_pred {
None => format!("`{}`", &p),
- Some((parent_p, _)) => {
- collect_type_param_suggestions(self_ty, parent_pred, &p);
- format!("`{}`\nwhich is required by `{}`", p, parent_p)
- }
- },
+ Some(parent_pred) => match format_pred(*parent_pred) {
+ None => format!("`{}`", &p),
+ Some((parent_p, _)) => {
+ collect_type_param_suggestions(
+ self_ty,
+ parent_pred,
+ &p,
+ );
+ format!("`{}`\nwhich is required by `{}`", p, parent_p)
+ }
+ },
+ }
})
})
.enumerate()
.collect::<Vec<(usize, String)>>();
+
for ((span, empty_where), obligations) in type_params.into_iter() {
restrict_type_params = true;
// #74886: Sort here so that the output is always the same.
for (span, msg) in bound_spans.into_iter() {
err.span_label(span, &msg);
}
- if !bound_list.is_empty() {
+ if !bound_list.is_empty() || !skip_list.is_empty() {
let bound_list = bound_list
.into_iter()
.map(|(_, path)| path)
err.set_primary_message(&format!(
"the {item_kind} `{item_name}` exists for {actual_prefix} `{ty_str}`, but its trait bounds were not satisfied"
));
- err.note(&format!(
- "the following trait bounds were not satisfied:\n{bound_list}"
- ));
+ if !bound_list.is_empty() {
+ err.note(&format!(
+ "the following trait bounds were not satisfied:\n{bound_list}"
+ ));
+ }
self.suggest_derive(&mut err, &unsatisfied_predicates);
unsatisfied_bounds = true;
err.span_note(spans, &msg);
}
- let preds: Vec<_> = errors.iter().map(|e| (e.obligation.predicate, None)).collect();
+ let preds: Vec<_> = errors
+ .iter()
+ .map(|e| (e.obligation.predicate, None, Some(e.obligation.cause.clone())))
+ .collect();
self.suggest_derive(err, &preds);
}
fn suggest_derive(
&self,
err: &mut DiagnosticBuilder<'_>,
- unsatisfied_predicates: &Vec<(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)>,
+ unsatisfied_predicates: &Vec<(
+ ty::Predicate<'tcx>,
+ Option<ty::Predicate<'tcx>>,
+ Option<ObligationCause<'tcx>>,
+ )>,
) {
let mut derives = Vec::<(String, Span, String)>::new();
let mut traits = Vec::<Span>::new();
- for (pred, _) in unsatisfied_predicates {
+ for (pred, _, _) in unsatisfied_predicates {
let trait_pred = match pred.kind().skip_binder() {
ty::PredicateKind::Trait(trait_pred) => trait_pred,
_ => continue,
item_name: Ident,
source: SelfSource<'tcx>,
valid_out_of_scope_traits: Vec<DefId>,
- unsatisfied_predicates: &[(ty::Predicate<'tcx>, Option<ty::Predicate<'tcx>>)],
+ unsatisfied_predicates: &[(
+ ty::Predicate<'tcx>,
+ Option<ty::Predicate<'tcx>>,
+ Option<ObligationCause<'tcx>>,
+ )],
unsatisfied_bounds: bool,
) {
let mut alt_rcvr_sugg = false;
// this isn't perfect (that is, there are cases when
// implementing a trait would be legal but is rejected
// here).
- unsatisfied_predicates.iter().all(|(p, _)| {
+ unsatisfied_predicates.iter().all(|(p, _, _)| {
match p.kind().skip_binder() {
// Hide traits if they are present in predicates as they can be fixed without
// having to implement them.
Node::GenericParam(param) => {
let mut impl_trait = false;
let has_bounds =
- if let hir::GenericParamKind::Type { synthetic: Some(_), .. } =
+ if let hir::GenericParamKind::Type { synthetic: true, .. } =
¶m.kind
{
// We've found `fn foo(x: impl Trait)` instead of
kind: ty::GenericParamDefKind::Type {
has_default: false,
object_lifetime_default: rl::Set1::Empty,
- synthetic: None,
+ synthetic: false,
},
});
kind: ty::GenericParamDefKind::Type {
has_default: false,
object_lifetime_default: rl::Set1::Empty,
- synthetic: None,
+ synthetic: false,
},
}));
}
kind: ty::GenericParamDefKind::Type {
has_default: false,
object_lifetime_default: rl::Set1::Empty,
- synthetic: None,
+ synthetic: false,
},
});
}
// prove that the trait applies to the types that were
// used, and adding the predicate into this list ensures
// that this is done.
- let mut span = tcx.def_span(def_id);
- if tcx.sess.source_map().is_local_span(span) {
- // `guess_head_span` reads the actual source file from
- // disk to try to determine the 'head' snippet of the span.
- // Don't do this for a span that comes from a file outside
- // of our crate, since this would make our query output
- // (and overall crate metadata) dependent on the
- // *current* state of an external file.
- span = tcx.sess.source_map().guess_head_span(span);
- }
+ //
+ // We use a DUMMY_SP here as a way to signal trait bounds that come
+ // from the trait itself that *shouldn't* be shown as the source of
+ // an obligation and instead be skipped. Otherwise we'd use
+ // `tcx.def_span(def_id);`
+ let span = rustc_span::DUMMY_SP;
result.predicates =
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once((
ty::TraitRef::identity(tcx, def_id).without_const().to_predicate(tcx),
} else if attr.has_name(sym::link_name) {
codegen_fn_attrs.link_name = attr.value_str();
} else if attr.has_name(sym::link_ordinal) {
- if link_ordinal_span.is_some() {
- tcx.sess
- .struct_span_err(
- attr.span,
- "multiple `link_ordinal` attributes on a single definition",
- )
- .emit();
- }
link_ordinal_span = Some(attr.span);
if let ordinal @ Some(_) = check_link_ordinal(tcx, attr) {
codegen_fn_attrs.link_ordinal = ordinal;
unsafe { self.ptr.as_ref() }
}
- fn from_inner(ptr: NonNull<RcBox<T>>) -> Self {
+ unsafe fn from_inner(ptr: NonNull<RcBox<T>>) -> Self {
Self { ptr, phantom: PhantomData }
}
unsafe fn from_ptr(ptr: *mut RcBox<T>) -> Self {
- Self::from_inner(unsafe { NonNull::new_unchecked(ptr) })
+ unsafe { Self::from_inner(NonNull::new_unchecked(ptr)) }
}
}
// pointers, which ensures that the weak destructor never frees
// the allocation while the strong destructor is running, even
// if the weak pointer is stored inside the strong one.
- Self::from_inner(
- Box::leak(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value }).into(),
- )
+ unsafe {
+ Self::from_inner(
+ Box::leak(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value }).into(),
+ )
+ }
}
/// Constructs a new `Rc<T>` using a weak reference to itself. Attempting
// otherwise.
let data = data_fn(&weak);
- unsafe {
+ let strong = unsafe {
let inner = init_ptr.as_ptr();
ptr::write(ptr::addr_of_mut!((*inner).value), data);
let prev_value = (*inner).strong.get();
debug_assert_eq!(prev_value, 0, "No prior strong references should exist");
(*inner).strong.set(1);
- }
- let strong = Rc::from_inner(init_ptr);
+ Rc::from_inner(init_ptr)
+ };
// Strong references should collectively own a shared weak reference,
// so don't run the destructor for our old weak reference.
// pointers, which ensures that the weak destructor never frees
// the allocation while the strong destructor is running, even
// if the weak pointer is stored inside the strong one.
- Ok(Self::from_inner(
- Box::leak(Box::try_new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value })?)
- .into(),
- ))
+ unsafe {
+ Ok(Self::from_inner(
+ Box::leak(Box::try_new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value })?)
+ .into(),
+ ))
+ }
}
/// Constructs a new `Rc` with uninitialized contents, returning an error if the allocation fails
#[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub unsafe fn assume_init(self) -> Rc<T> {
- Rc::from_inner(mem::ManuallyDrop::new(self).ptr.cast())
+ unsafe { Rc::from_inner(mem::ManuallyDrop::new(self).ptr.cast()) }
}
}
/// ```
pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<dyn Any>> {
if (*self).is::<T>() {
- let ptr = self.ptr.cast::<RcBox<T>>();
- forget(self);
- Ok(Rc::from_inner(ptr))
+ unsafe {
+ let ptr = self.ptr.cast::<RcBox<T>>();
+ forget(self);
+ Ok(Rc::from_inner(ptr))
+ }
} else {
Err(self)
}
/// ```
#[inline]
fn clone(&self) -> Rc<T> {
- self.inner().inc_strong();
- Self::from_inner(self.ptr)
+ unsafe {
+ self.inner().inc_strong();
+ Self::from_inner(self.ptr)
+ }
}
}
#[stable(feature = "rc_weak", since = "1.4.0")]
pub fn upgrade(&self) -> Option<Rc<T>> {
let inner = self.inner()?;
+
if inner.strong() == 0 {
None
} else {
- inner.inc_strong();
- Some(Rc::from_inner(self.ptr))
+ unsafe {
+ inner.inc_strong();
+ Some(Rc::from_inner(self.ptr))
+ }
}
}
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Arc<U>> for Arc<T> {}
impl<T: ?Sized> Arc<T> {
- fn from_inner(ptr: NonNull<ArcInner<T>>) -> Self {
+ unsafe fn from_inner(ptr: NonNull<ArcInner<T>>) -> Self {
Self { ptr, phantom: PhantomData }
}
weak: atomic::AtomicUsize::new(1),
data,
};
- Self::from_inner(Box::leak(x).into())
+ unsafe { Self::from_inner(Box::leak(x).into()) }
}
/// Constructs a new `Arc<T>` using a weak reference to itself. Attempting
// Now we can properly initialize the inner value and turn our weak
// reference into a strong reference.
- unsafe {
+ let strong = unsafe {
let inner = init_ptr.as_ptr();
ptr::write(ptr::addr_of_mut!((*inner).data), data);
// possible with safe code alone.
let prev_value = (*inner).strong.fetch_add(1, Release);
debug_assert_eq!(prev_value, 0, "No prior strong references should exist");
- }
- let strong = Arc::from_inner(init_ptr);
+ Arc::from_inner(init_ptr)
+ };
// Strong references should collectively own a shared weak reference,
// so don't run the destructor for our old weak reference.
weak: atomic::AtomicUsize::new(1),
data,
})?;
- Ok(Self::from_inner(Box::leak(x).into()))
+ unsafe { Ok(Self::from_inner(Box::leak(x).into())) }
}
/// Constructs a new `Arc` with uninitialized contents, returning an error
#[must_use = "`self` will be dropped if the result is not used"]
#[inline]
pub unsafe fn assume_init(self) -> Arc<T> {
- Arc::from_inner(mem::ManuallyDrop::new(self).ptr.cast())
+ unsafe { Arc::from_inner(mem::ManuallyDrop::new(self).ptr.cast()) }
}
}
abort();
}
- Self::from_inner(self.ptr)
+ unsafe { Self::from_inner(self.ptr) }
}
}
T: Any + Send + Sync + 'static,
{
if (*self).is::<T>() {
- let ptr = self.ptr.cast::<ArcInner<T>>();
- mem::forget(self);
- Ok(Arc::from_inner(ptr))
+ unsafe {
+ let ptr = self.ptr.cast::<ArcInner<T>>();
+ mem::forget(self);
+ Ok(Arc::from_inner(ptr))
+ }
} else {
Err(self)
}
// value can be initialized after `Weak` references have already been created. In that case, we
// expect to observe the fully initialized value.
match inner.strong.compare_exchange_weak(n, n + 1, Acquire, Relaxed) {
- Ok(_) => return Some(Arc::from_inner(self.ptr)), // null checked above
+ Ok(_) => return Some(unsafe { Arc::from_inner(self.ptr) }), // null checked above
Err(old) => n = old,
}
}
/// The removed element is replaced by the last element of the vector.
///
/// This does not preserve ordering, but is *O*(1).
+ /// If you need to preserve the element order, use [`remove`] instead.
+ ///
+ /// [`remove`]: Vec::remove
///
/// # Panics
///
/// shifting all elements after it to the left.
///
/// Note: Because this shifts over the remaining elements, it has a
- /// worst-case performance of O(n). If you don't need the order of elements
+ /// worst-case performance of *O*(*n*). If you don't need the order of elements
/// to be preserved, use [`swap_remove`] instead.
///
/// [`swap_remove`]: Vec::swap_remove
#![feature(const_btree_new)]
#![feature(const_default_impls)]
#![feature(const_trait_impl)]
+#![feature(const_str_from_utf8)]
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
+use std::assert_matches::assert_matches;
use std::borrow::Cow;
use std::cmp::Ordering::{Equal, Greater, Less};
use std::str::{from_utf8, from_utf8_unchecked};
assert!(from_utf8(&[0xF4, 0x8F, 0xBF, 0xBF]).is_ok());
}
+#[test]
+fn test_const_is_utf8() {
+ const _: () = {
+ // deny overlong encodings
+ assert!(from_utf8(&[0xc0, 0x80]).is_err());
+ assert!(from_utf8(&[0xc0, 0xae]).is_err());
+ assert!(from_utf8(&[0xe0, 0x80, 0x80]).is_err());
+ assert!(from_utf8(&[0xe0, 0x80, 0xaf]).is_err());
+ assert!(from_utf8(&[0xe0, 0x81, 0x81]).is_err());
+ assert!(from_utf8(&[0xf0, 0x82, 0x82, 0xac]).is_err());
+ assert!(from_utf8(&[0xf4, 0x90, 0x80, 0x80]).is_err());
+
+ // deny surrogates
+ assert!(from_utf8(&[0xED, 0xA0, 0x80]).is_err());
+ assert!(from_utf8(&[0xED, 0xBF, 0xBF]).is_err());
+
+ assert!(from_utf8(&[0xC2, 0x80]).is_ok());
+ assert!(from_utf8(&[0xDF, 0xBF]).is_ok());
+ assert!(from_utf8(&[0xE0, 0xA0, 0x80]).is_ok());
+ assert!(from_utf8(&[0xED, 0x9F, 0xBF]).is_ok());
+ assert!(from_utf8(&[0xEE, 0x80, 0x80]).is_ok());
+ assert!(from_utf8(&[0xEF, 0xBF, 0xBF]).is_ok());
+ assert!(from_utf8(&[0xF0, 0x90, 0x80, 0x80]).is_ok());
+ assert!(from_utf8(&[0xF4, 0x8F, 0xBF, 0xBF]).is_ok());
+ };
+}
+
#[test]
fn from_utf8_mostly_ascii() {
// deny invalid bytes embedded in long stretches of ascii
}
}
+#[test]
+fn const_from_utf8_mostly_ascii() {
+ const _: () = {
+ // deny invalid bytes embedded in long stretches of ascii
+ let mut i = 32;
+ while i < 64 {
+ let mut data = [0; 128];
+ data[i] = 0xC0;
+ assert!(from_utf8(&data).is_err());
+ data[i] = 0xC2;
+ assert!(from_utf8(&data).is_err());
+
+ i = i + 1;
+ }
+ };
+}
+
#[test]
fn from_utf8_error() {
macro_rules! test {
- ($input: expr, $expected_valid_up_to: expr, $expected_error_len: expr) => {
+ ($input: expr, $expected_valid_up_to:pat, $expected_error_len:pat) => {
let error = from_utf8($input).unwrap_err();
- assert_eq!(error.valid_up_to(), $expected_valid_up_to);
- assert_eq!(error.error_len(), $expected_error_len);
+ assert_matches!(error.valid_up_to(), $expected_valid_up_to);
+ assert_matches!(error.error_len(), $expected_error_len);
+
+ const _: () = {
+ match from_utf8($input) {
+ Err(error) => {
+ let valid_up_to = error.valid_up_to();
+ let error_len = error.error_len();
+
+ assert!(matches!(valid_up_to, $expected_valid_up_to));
+ assert!(matches!(error_len, $expected_error_len));
+ }
+ Ok(_) => unreachable!(),
+ }
+ };
};
}
test!(b"A\xC3\xA9 \xFF ", 4, Some(1));
#[must_use]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
-pub fn from_u32(i: u32) -> Option<char> {
- char::try_from(i).ok()
+#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
+pub const fn from_u32(i: u32) -> Option<char> {
+ // FIXME: once Result::ok is const fn, use it here
+ match char_try_from_u32(i) {
+ Ok(c) => Some(c),
+ Err(_) => None,
+ }
}
/// Converts a `u32` to a `char`, ignoring validity.
#[inline]
#[must_use]
#[stable(feature = "char_from_unchecked", since = "1.5.0")]
-pub unsafe fn from_u32_unchecked(i: u32) -> char {
+#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
+pub const unsafe fn from_u32_unchecked(i: u32) -> char {
// SAFETY: the caller must guarantee that `i` is a valid char value.
if cfg!(debug_assertions) { char::from_u32(i).unwrap() } else { unsafe { transmute(i) } }
}
}
}
+#[inline]
+const fn char_try_from_u32(i: u32) -> Result<char, CharTryFromError> {
+ if (i > MAX as u32) || (i >= 0xD800 && i <= 0xDFFF) {
+ Err(CharTryFromError(()))
+ } else {
+ // SAFETY: checked that it's a legal unicode value
+ Ok(unsafe { transmute(i) })
+ }
+}
+
#[stable(feature = "try_from", since = "1.34.0")]
impl TryFrom<u32> for char {
type Error = CharTryFromError;
#[inline]
fn try_from(i: u32) -> Result<Self, Self::Error> {
- if (i > MAX as u32) || (i >= 0xD800 && i <= 0xDFFF) {
- Err(CharTryFromError(()))
- } else {
- // SAFETY: checked that it's a legal unicode value
- Ok(unsafe { transmute(i) })
- }
+ char_try_from_u32(i)
}
}
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
-pub fn from_digit(num: u32, radix: u32) -> Option<char> {
+#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
+pub const fn from_digit(num: u32, radix: u32) -> Option<char> {
if radix > 36 {
panic!("from_digit: radix is too high (maximum 36)");
}
/// assert_eq!(None, c);
/// ```
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
+ #[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
#[must_use]
#[inline]
- pub fn from_u32(i: u32) -> Option<char> {
+ pub const fn from_u32(i: u32) -> Option<char> {
super::convert::from_u32(i)
}
/// assert_eq!('❤', c);
/// ```
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
+ #[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
#[must_use]
#[inline]
- pub unsafe fn from_u32_unchecked(i: u32) -> char {
+ pub const unsafe fn from_u32_unchecked(i: u32) -> char {
// SAFETY: the safety contract must be upheld by the caller.
unsafe { super::convert::from_u32_unchecked(i) }
}
/// let _c = char::from_digit(1, 37);
/// ```
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
+ #[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
#[must_use]
#[inline]
- pub fn from_digit(num: u32, radix: u32) -> Option<char> {
+ pub const fn from_digit(num: u32, radix: u32) -> Option<char> {
super::convert::from_digit(num, radix)
}
/// let _ = '1'.to_digit(37);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
+ #[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
- pub fn to_digit(self, radix: u32) -> Option<u32> {
+ pub const fn to_digit(self, radix: u32) -> Option<u32> {
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
// If not a digit, a number greater than radix will be created.
let mut digit = (self as u32).wrapping_sub('0' as u32);
// Force the 6th bit to be set to ensure ascii is lower case.
digit = (self as u32 | 0b10_0000).wrapping_sub('a' as u32).saturating_add(10);
}
- (digit < radix).then_some(digit)
+ // FIXME: once then_some is const fn, use it here
+ if digit < radix { Some(digit) } else { None }
}
/// Returns an iterator that yields the hexadecimal Unicode escape of a
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(uppercase_a.is_ascii_alphabetic());
/// assert!(uppercase_g.is_ascii_alphabetic());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(uppercase_a.is_ascii_uppercase());
/// assert!(uppercase_g.is_ascii_uppercase());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(!uppercase_a.is_ascii_lowercase());
/// assert!(!uppercase_g.is_ascii_lowercase());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(uppercase_a.is_ascii_alphanumeric());
/// assert!(uppercase_g.is_ascii_alphanumeric());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(!uppercase_a.is_ascii_digit());
/// assert!(!uppercase_g.is_ascii_digit());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(uppercase_a.is_ascii_hexdigit());
/// assert!(!uppercase_g.is_ascii_hexdigit());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(!uppercase_a.is_ascii_punctuation());
/// assert!(!uppercase_g.is_ascii_punctuation());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(uppercase_a.is_ascii_graphic());
/// assert!(uppercase_g.is_ascii_graphic());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(!uppercase_a.is_ascii_whitespace());
/// assert!(!uppercase_g.is_ascii_whitespace());
/// let percent = '%';
/// let space = ' ';
/// let lf = '\n';
- /// let esc: char = 0x1b_u8.into();
+ /// let esc = '\x1b';
///
/// assert!(!uppercase_a.is_ascii_control());
/// assert!(!uppercase_g.is_ascii_control());
#![allow(explicit_outlives_requirements)]
//
// Library features for const fns:
+#![feature(const_align_offset)]
#![feature(const_align_of_val)]
#![feature(const_alloc_layout)]
#![feature(const_arguments_as_str)]
#![feature(const_bigint_helper_methods)]
#![feature(const_caller_location)]
#![feature(const_cell_into_inner)]
+#![feature(const_char_convert)]
#![feature(const_discriminant)]
#![feature(const_eval_select)]
#![feature(const_float_bits_conv)]
#![feature(const_size_of_val)]
#![feature(const_slice_from_raw_parts)]
#![feature(const_slice_ptr_len)]
+#![feature(const_str_from_utf8_unchecked_mut)]
#![feature(const_swap)]
#![feature(const_trait_impl)]
#![feature(const_type_id)]
#![feature(duration_consts_2)]
#![feature(ptr_metadata)]
#![feature(slice_ptr_get)]
+#![feature(str_internals)]
#![feature(variant_count)]
#![feature(const_array_from_ref)]
#![feature(const_slice_from_ref)]
#![cfg_attr(bootstrap, feature(const_raw_ptr_deref))]
#![feature(const_refs_to_cell)]
#![feature(decl_macro)]
+#![feature(derive_default_enum)]
#![feature(doc_cfg)]
#![feature(doc_notable_trait)]
#![feature(doc_primitive)]
/// Returns the maximum of the two numbers.
///
+ /// Follows the IEEE-754 2008 semantics for maxNum, except for handling of signaling NaNs.
+ /// This matches the behavior of libm’s fmin.
+ ///
/// ```
/// let x = 1.0f32;
/// let y = 2.0f32;
/// Returns the minimum of the two numbers.
///
+ /// Follows the IEEE-754 2008 semantics for minNum, except for handling of signaling NaNs.
+ /// This matches the behavior of libm’s fmin.
+ ///
/// ```
/// let x = 1.0f32;
/// let y = 2.0f32;
intrinsics::minnumf32(self, other)
}
+ /// Returns the maximum of the two numbers, propagating NaNs.
+ ///
+ /// This returns NaN when *either* argument is NaN, as opposed to
+ /// [`f32::max`] which only returns NaN when *both* arguments are NaN.
+ ///
+ /// ```
+ /// #![feature(float_minimum_maximum)]
+ /// let x = 1.0f32;
+ /// let y = 2.0f32;
+ ///
+ /// assert_eq!(x.maximum(y), y);
+ /// assert!(x.maximum(f32::NAN).is_nan());
+ /// ```
+ ///
+ /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
+ /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
+ /// Note that this follows the semantics specified in IEEE 754-2019.
+ #[unstable(feature = "float_minimum_maximum", issue = "91079")]
+ #[inline]
+ pub fn maximum(self, other: f32) -> f32 {
+ if self > other {
+ self
+ } else if other > self {
+ other
+ } else if self == other {
+ if self.is_sign_positive() && other.is_sign_negative() { self } else { other }
+ } else {
+ self + other
+ }
+ }
+
+ /// Returns the minimum of the two numbers, propagating NaNs.
+ ///
+ /// This returns NaN when *either* argument is NaN, as opposed to
+ /// [`f32::min`] which only returns NaN when *both* arguments are NaN.
+ ///
+ /// ```
+ /// #![feature(float_minimum_maximum)]
+ /// let x = 1.0f32;
+ /// let y = 2.0f32;
+ ///
+ /// assert_eq!(x.minimum(y), x);
+ /// assert!(x.minimum(f32::NAN).is_nan());
+ /// ```
+ ///
+ /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
+ /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
+ /// Note that this follows the semantics specified in IEEE 754-2019.
+ #[unstable(feature = "float_minimum_maximum", issue = "91079")]
+ #[inline]
+ pub fn minimum(self, other: f32) -> f32 {
+ if self < other {
+ self
+ } else if other < self {
+ other
+ } else if self == other {
+ if self.is_sign_negative() && other.is_sign_positive() { self } else { other }
+ } else {
+ self + other
+ }
+ }
+
/// Rounds toward zero and converts to any primitive integer type,
/// assuming that the value is finite and fits in that type.
///
/// Returns the maximum of the two numbers.
///
+ /// Follows the IEEE-754 2008 semantics for maxNum, except for handling of signaling NaNs.
+ /// This matches the behavior of libm’s fmin.
+ ///
/// ```
/// let x = 1.0_f64;
/// let y = 2.0_f64;
/// Returns the minimum of the two numbers.
///
+ /// Follows the IEEE-754 2008 semantics for minNum, except for handling of signaling NaNs.
+ /// This matches the behavior of libm’s fmin.
+ ///
/// ```
/// let x = 1.0_f64;
/// let y = 2.0_f64;
intrinsics::minnumf64(self, other)
}
+ /// Returns the maximum of the two numbers, propagating NaNs.
+ ///
+ /// This returns NaN when *either* argument is NaN, as opposed to
+ /// [`f64::max`] which only returns NaN when *both* arguments are NaN.
+ ///
+ /// ```
+ /// #![feature(float_minimum_maximum)]
+ /// let x = 1.0_f64;
+ /// let y = 2.0_f64;
+ ///
+ /// assert_eq!(x.maximum(y), y);
+ /// assert!(x.maximum(f64::NAN).is_nan());
+ /// ```
+ ///
+ /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the greater
+ /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
+ /// Note that this follows the semantics specified in IEEE 754-2019.
+ #[unstable(feature = "float_minimum_maximum", issue = "91079")]
+ #[inline]
+ pub fn maximum(self, other: f64) -> f64 {
+ if self > other {
+ self
+ } else if other > self {
+ other
+ } else if self == other {
+ if self.is_sign_positive() && other.is_sign_negative() { self } else { other }
+ } else {
+ self + other
+ }
+ }
+
+ /// Returns the minimum of the two numbers, propagating NaNs.
+ ///
+ /// This returns NaN when *either* argument is NaN, as opposed to
+ /// [`f64::min`] which only returns NaN when *both* arguments are NaN.
+ ///
+ /// ```
+ /// #![feature(float_minimum_maximum)]
+ /// let x = 1.0_f64;
+ /// let y = 2.0_f64;
+ ///
+ /// assert_eq!(x.minimum(y), x);
+ /// assert!(x.minimum(f64::NAN).is_nan());
+ /// ```
+ ///
+ /// If one of the arguments is NaN, then NaN is returned. Otherwise this returns the lesser
+ /// of the two numbers. For this operation, -0.0 is considered to be less than +0.0.
+ /// Note that this follows the semantics specified in IEEE 754-2019.
+ #[unstable(feature = "float_minimum_maximum", issue = "91079")]
+ #[inline]
+ pub fn minimum(self, other: f64) -> f64 {
+ if self < other {
+ self
+ } else if other < self {
+ other
+ } else if self == other {
+ if self.is_sign_negative() && other.is_sign_positive() { self } else { other }
+ } else {
+ self + other
+ }
+ }
+
/// Rounds toward zero and converts to any primitive integer type,
/// assuming that the value is finite and fits in that type.
///
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(uppercase_a.is_ascii_alphabetic());
/// assert!(uppercase_g.is_ascii_alphabetic());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(uppercase_a.is_ascii_uppercase());
/// assert!(uppercase_g.is_ascii_uppercase());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(!uppercase_a.is_ascii_lowercase());
/// assert!(!uppercase_g.is_ascii_lowercase());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(uppercase_a.is_ascii_alphanumeric());
/// assert!(uppercase_g.is_ascii_alphanumeric());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(!uppercase_a.is_ascii_digit());
/// assert!(!uppercase_g.is_ascii_digit());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(uppercase_a.is_ascii_hexdigit());
/// assert!(!uppercase_g.is_ascii_hexdigit());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(!uppercase_a.is_ascii_punctuation());
/// assert!(!uppercase_g.is_ascii_punctuation());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(uppercase_a.is_ascii_graphic());
/// assert!(uppercase_g.is_ascii_graphic());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(!uppercase_a.is_ascii_whitespace());
/// assert!(!uppercase_g.is_ascii_whitespace());
/// let percent = b'%';
/// let space = b' ';
/// let lf = b'\n';
- /// let esc = 0x1b_u8;
+ /// let esc = b'\x1b';
///
/// assert!(!uppercase_a.is_ascii_control());
/// assert!(!uppercase_g.is_ascii_control());
/// * [`Clone`] \(Note that this will not defer to `T`'s `Clone` implementation if it exists!)
/// * [`Deref`]
/// * [`Borrow`]
-/// * [`Pointer`]
+/// * [`fmt::Pointer`]
///
/// [`Deref`]: ops::Deref
/// [`Borrow`]: borrow::Borrow
-/// [`Pointer`]: fmt::Pointer
///
/// `&mut T` references get all of the above except `Copy` and `Clone` (to prevent creating
/// multiple simultaneous mutable borrows), plus the following, regardless of the type of its
/// The following traits are implemented on `&T` references if the underlying `T` also implements
/// that trait:
///
-/// * All the traits in [`std::fmt`] except [`Pointer`] and [`fmt::Write`]
+/// * All the traits in [`std::fmt`] except [`fmt::Pointer`] (which is implemented regardless of the type of its referent) and [`fmt::Write`]
/// * [`PartialOrd`]
/// * [`Ord`]
/// * [`PartialEq`]
/// * [`Fn`] \(in addition, `&T` references get [`FnMut`] and [`FnOnce`] if `T: Fn`)
/// * [`Hash`]
/// * [`ToSocketAddrs`]
+/// * [`Send`] \(`&T` references also require <code>T: [Sync]</code>)
///
/// [`std::fmt`]: fmt
-/// ['Pointer`]: fmt::Pointer
/// [`Hash`]: hash::Hash
#[doc = concat!("[`ToSocketAddrs`]: ", include_str!("../primitive_docs/net_tosocketaddrs.md"))]
///
/// * [`ExactSizeIterator`]
/// * [`FusedIterator`]
/// * [`TrustedLen`]
-/// * [`Send`] \(note that `&T` references only get `Send` if <code>T: [Sync]</code>)
/// * [`io::Write`]
/// * [`Read`]
/// * [`Seek`]
/// assert_eq!("💖", sparkle_heart);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
-pub fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
- run_utf8_validation(v)?;
- // SAFETY: Just ran validation.
- Ok(unsafe { from_utf8_unchecked(v) })
+#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
+pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
+ // This should use `?` again, once it's `const`
+ match run_utf8_validation(v) {
+ Ok(_) => {
+ // SAFETY: validation succeeded.
+ Ok(unsafe { from_utf8_unchecked(v) })
+ }
+ Err(err) => Err(err),
+ }
}
/// Converts a mutable slice of bytes to a mutable string slice.
/// See the docs for [`Utf8Error`] for more details on the kinds of
/// errors that can be returned.
#[stable(feature = "str_mut_extras", since = "1.20.0")]
-pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
- run_utf8_validation(v)?;
- // SAFETY: Just ran validation.
- Ok(unsafe { from_utf8_unchecked_mut(v) })
+#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
+pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
+ // This should use `?` again, once it's `const`
+ match run_utf8_validation(v) {
+ Ok(_) => {
+ // SAFETY: validation succeeded.
+ Ok(unsafe { from_utf8_unchecked_mut(v) })
+ }
+ Err(err) => Err(err),
+ }
}
/// Converts a slice of bytes to a string slice without checking
#[inline]
#[must_use]
#[stable(feature = "str_mut_extras", since = "1.20.0")]
-pub unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
+#[rustc_const_unstable(feature = "const_str_from_utf8_unchecked_mut", issue = "91005")]
+pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
// SAFETY: the caller must guarantee that the bytes `v`
// are valid UTF-8, thus the cast to `*mut str` is safe.
// Also, the pointer dereference is safe because that pointer
/// assert_eq!(1, error.valid_up_to());
/// ```
#[stable(feature = "utf8_error", since = "1.5.0")]
+ #[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
#[must_use]
#[inline]
- pub fn valid_up_to(&self) -> usize {
+ pub const fn valid_up_to(&self) -> usize {
self.valid_up_to
}
///
/// [U+FFFD]: ../../std/char/constant.REPLACEMENT_CHARACTER.html
#[stable(feature = "utf8_error_error_len", since = "1.20.0")]
+ #[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
#[must_use]
#[inline]
- pub fn error_len(&self) -> Option<usize> {
- self.error_len.map(|len| len as usize)
+ pub const fn error_len(&self) -> Option<usize> {
+ // This should become `map` again, once it's `const`
+ match self.error_len {
+ Some(len) => Some(len as usize),
+ None => None,
+ }
}
}
#[inline]
fn next(&mut self) -> Option<char> {
- next_code_point(&mut self.iter).map(|ch| {
- // SAFETY: `str` invariant says `ch` is a valid Unicode Scalar Value.
- unsafe { char::from_u32_unchecked(ch) }
- })
+ // SAFETY: `str` invariant says `self.iter` is a valid UTF-8 string and
+ // the resulting `ch` is a valid Unicode Scalar Value.
+ unsafe { next_code_point(&mut self.iter).map(|ch| char::from_u32_unchecked(ch)) }
}
#[inline]
impl<'a> DoubleEndedIterator for Chars<'a> {
#[inline]
fn next_back(&mut self) -> Option<char> {
- next_code_point_reverse(&mut self.iter).map(|ch| {
- // SAFETY: `str` invariant says `ch` is a valid Unicode Scalar Value.
- unsafe { char::from_u32_unchecked(ch) }
- })
+ // SAFETY: `str` invariant says `self.iter` is a valid UTF-8 string and
+ // the resulting `ch` is a valid Unicode Scalar Value.
+ unsafe { next_code_point_reverse(&mut self.iter).map(|ch| char::from_u32_unchecked(ch)) }
}
}
/// The first byte is special, only want bottom 5 bits for width 2, 4 bits
/// for width 3, and 3 bits for width 4.
#[inline]
-fn utf8_first_byte(byte: u8, width: u32) -> u32 {
+const fn utf8_first_byte(byte: u8, width: u32) -> u32 {
(byte & (0x7F >> width)) as u32
}
/// Returns the value of `ch` updated with continuation byte `byte`.
#[inline]
-fn utf8_acc_cont_byte(ch: u32, byte: u8) -> u32 {
+const fn utf8_acc_cont_byte(ch: u32, byte: u8) -> u32 {
(ch << 6) | (byte & CONT_MASK) as u32
}
/// Checks whether the byte is a UTF-8 continuation byte (i.e., starts with the
/// bits `10`).
#[inline]
-pub(super) fn utf8_is_cont_byte(byte: u8) -> bool {
+pub(super) const fn utf8_is_cont_byte(byte: u8) -> bool {
(byte as i8) < -64
}
-#[inline]
-fn unwrap_or_0(opt: Option<&u8>) -> u8 {
- match opt {
- Some(&byte) => byte,
- None => 0,
- }
-}
-
/// Reads the next code point out of a byte iterator (assuming a
/// UTF-8-like encoding).
+///
+/// # Safety
+///
+/// `bytes` must produce a valid UTF-8-like (UTF-8 or WTF-8) string
#[unstable(feature = "str_internals", issue = "none")]
#[inline]
-pub fn next_code_point<'a, I: Iterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> {
+pub unsafe fn next_code_point<'a, I: Iterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> {
// Decode UTF-8
let x = *bytes.next()?;
if x < 128 {
// Decode from a byte combination out of: [[[x y] z] w]
// NOTE: Performance is sensitive to the exact formulation here
let init = utf8_first_byte(x, 2);
- let y = unwrap_or_0(bytes.next());
+ // SAFETY: `bytes` produces an UTF-8-like string,
+ // so the iterator must produce a value here.
+ let y = unsafe { *bytes.next().unwrap_unchecked() };
let mut ch = utf8_acc_cont_byte(init, y);
if x >= 0xE0 {
// [[x y z] w] case
// 5th bit in 0xE0 .. 0xEF is always clear, so `init` is still valid
- let z = unwrap_or_0(bytes.next());
+ // SAFETY: `bytes` produces an UTF-8-like string,
+ // so the iterator must produce a value here.
+ let z = unsafe { *bytes.next().unwrap_unchecked() };
let y_z = utf8_acc_cont_byte((y & CONT_MASK) as u32, z);
ch = init << 12 | y_z;
if x >= 0xF0 {
// [x y z w] case
// use only the lower 3 bits of `init`
- let w = unwrap_or_0(bytes.next());
+ // SAFETY: `bytes` produces an UTF-8-like string,
+ // so the iterator must produce a value here.
+ let w = unsafe { *bytes.next().unwrap_unchecked() };
ch = (init & 7) << 18 | utf8_acc_cont_byte(y_z, w);
}
}
/// Reads the last code point out of a byte iterator (assuming a
/// UTF-8-like encoding).
+///
+/// # Safety
+///
+/// `bytes` must produce a valid UTF-8-like (UTF-8 or WTF-8) string
#[inline]
-pub(super) fn next_code_point_reverse<'a, I>(bytes: &mut I) -> Option<u32>
+pub(super) unsafe fn next_code_point_reverse<'a, I>(bytes: &mut I) -> Option<u32>
where
I: DoubleEndedIterator<Item = &'a u8>,
{
// Multibyte case follows
// Decode from a byte combination out of: [x [y [z w]]]
let mut ch;
- let z = unwrap_or_0(bytes.next_back());
+ // SAFETY: `bytes` produces an UTF-8-like string,
+ // so the iterator must produce a value here.
+ let z = unsafe { *bytes.next_back().unwrap_unchecked() };
ch = utf8_first_byte(z, 2);
if utf8_is_cont_byte(z) {
- let y = unwrap_or_0(bytes.next_back());
+ // SAFETY: `bytes` produces an UTF-8-like string,
+ // so the iterator must produce a value here.
+ let y = unsafe { *bytes.next_back().unwrap_unchecked() };
ch = utf8_first_byte(y, 3);
if utf8_is_cont_byte(y) {
- let x = unwrap_or_0(bytes.next_back());
+ // SAFETY: `bytes` produces an UTF-8-like string,
+ // so the iterator must produce a value here.
+ let x = unsafe { *bytes.next_back().unwrap_unchecked() };
ch = utf8_first_byte(x, 4);
ch = utf8_acc_cont_byte(ch, y);
}
/// Returns `true` if any byte in the word `x` is nonascii (>= 128).
#[inline]
-fn contains_nonascii(x: usize) -> bool {
+const fn contains_nonascii(x: usize) -> bool {
(x & NONASCII_MASK) != 0
}
/// Walks through `v` checking that it's a valid UTF-8 sequence,
/// returning `Ok(())` in that case, or, if it is invalid, `Err(err)`.
#[inline(always)]
-pub(super) fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
+#[rustc_const_unstable(feature = "str_internals", issue = "none")]
+pub(super) const fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
let mut index = 0;
let len = v.len();
let first = v[index];
if first >= 128 {
- let w = UTF8_CHAR_WIDTH[first as usize];
+ let w = utf8_char_width(first);
// 2-byte encoding is for codepoints \u{0080} to \u{07ff}
// first C2 80 last DF BF
// 3-byte encoding is for codepoints \u{0800} to \u{ffff}
}
// https://tools.ietf.org/html/rfc3629
-static UTF8_CHAR_WIDTH: [u8; 256] = [
+const UTF8_CHAR_WIDTH: &[u8; 256] = &[
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, // 0x1F
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
#[unstable(feature = "str_internals", issue = "none")]
#[must_use]
#[inline]
-pub fn utf8_char_width(b: u8) -> usize {
+pub const fn utf8_char_width(b: u8) -> usize {
UTF8_CHAR_WIDTH[b as usize] as usize
}
#![feature(extern_types)]
#![feature(flt2dec)]
#![feature(fmt_internals)]
+#![feature(float_minimum_maximum)]
#![feature(array_from_fn)]
#![feature(hashmap_internals)]
#![feature(try_find)]
assert!(($nan as $fty).max($nan).is_nan());
}
#[test]
+ fn minimum() {
+ assert_eq!((0.0 as $fty).minimum(0.0), 0.0);
+ assert!((0.0 as $fty).minimum(0.0).is_sign_positive());
+ assert_eq!((-0.0 as $fty).minimum(0.0), -0.0);
+ assert!((-0.0 as $fty).minimum(0.0).is_sign_negative());
+ assert_eq!((-0.0 as $fty).minimum(-0.0), -0.0);
+ assert!((-0.0 as $fty).minimum(-0.0).is_sign_negative());
+ assert_eq!((9.0 as $fty).minimum(9.0), 9.0);
+ assert_eq!((-9.0 as $fty).minimum(0.0), -9.0);
+ assert_eq!((0.0 as $fty).minimum(9.0), 0.0);
+ assert!((0.0 as $fty).minimum(9.0).is_sign_positive());
+ assert_eq!((-0.0 as $fty).minimum(9.0), -0.0);
+ assert!((-0.0 as $fty).minimum(9.0).is_sign_negative());
+ assert_eq!((-0.0 as $fty).minimum(-9.0), -9.0);
+ assert_eq!(($inf as $fty).minimum(9.0), 9.0);
+ assert_eq!((9.0 as $fty).minimum($inf), 9.0);
+ assert_eq!(($inf as $fty).minimum(-9.0), -9.0);
+ assert_eq!((-9.0 as $fty).minimum($inf), -9.0);
+ assert_eq!(($neginf as $fty).minimum(9.0), $neginf);
+ assert_eq!((9.0 as $fty).minimum($neginf), $neginf);
+ assert_eq!(($neginf as $fty).minimum(-9.0), $neginf);
+ assert_eq!((-9.0 as $fty).minimum($neginf), $neginf);
+ assert!(($nan as $fty).minimum(9.0).is_nan());
+ assert!(($nan as $fty).minimum(-9.0).is_nan());
+ assert!((9.0 as $fty).minimum($nan).is_nan());
+ assert!((-9.0 as $fty).minimum($nan).is_nan());
+ assert!(($nan as $fty).minimum($nan).is_nan());
+ }
+ #[test]
+ fn maximum() {
+ assert_eq!((0.0 as $fty).maximum(0.0), 0.0);
+ assert!((0.0 as $fty).maximum(0.0).is_sign_positive());
+ assert_eq!((-0.0 as $fty).maximum(0.0), 0.0);
+ assert!((-0.0 as $fty).maximum(0.0).is_sign_positive());
+ assert_eq!((-0.0 as $fty).maximum(-0.0), -0.0);
+ assert!((-0.0 as $fty).maximum(-0.0).is_sign_negative());
+ assert_eq!((9.0 as $fty).maximum(9.0), 9.0);
+ assert_eq!((-9.0 as $fty).maximum(0.0), 0.0);
+ assert!((-9.0 as $fty).maximum(0.0).is_sign_positive());
+ assert_eq!((-9.0 as $fty).maximum(-0.0), -0.0);
+ assert!((-9.0 as $fty).maximum(-0.0).is_sign_negative());
+ assert_eq!((0.0 as $fty).maximum(9.0), 9.0);
+ assert_eq!((0.0 as $fty).maximum(-9.0), 0.0);
+ assert!((0.0 as $fty).maximum(-9.0).is_sign_positive());
+ assert_eq!((-0.0 as $fty).maximum(-9.0), -0.0);
+ assert!((-0.0 as $fty).maximum(-9.0).is_sign_negative());
+ assert_eq!(($inf as $fty).maximum(9.0), $inf);
+ assert_eq!((9.0 as $fty).maximum($inf), $inf);
+ assert_eq!(($inf as $fty).maximum(-9.0), $inf);
+ assert_eq!((-9.0 as $fty).maximum($inf), $inf);
+ assert_eq!(($neginf as $fty).maximum(9.0), 9.0);
+ assert_eq!((9.0 as $fty).maximum($neginf), 9.0);
+ assert_eq!(($neginf as $fty).maximum(-9.0), -9.0);
+ assert_eq!((-9.0 as $fty).maximum($neginf), -9.0);
+ assert!(($nan as $fty).maximum(9.0).is_nan());
+ assert!(($nan as $fty).maximum(-9.0).is_nan());
+ assert!((9.0 as $fty).maximum($nan).is_nan());
+ assert!((-9.0 as $fty).maximum($nan).is_nan());
+ assert!(($nan as $fty).maximum($nan).is_nan());
+ }
+ #[test]
fn rem_euclid() {
let a: $fty = 42.0;
assert!($inf.rem_euclid(a).is_nan());
assert_eq!(2.0f32.max(f32::NAN), 2.0);
}
+#[test]
+fn test_minimum() {
+ assert!(f32::NAN.minimum(2.0).is_nan());
+ assert!(2.0f32.minimum(f32::NAN).is_nan());
+}
+
+#[test]
+fn test_maximum() {
+ assert!(f32::NAN.maximum(2.0).is_nan());
+ assert!(2.0f32.maximum(f32::NAN).is_nan());
+}
+
#[test]
fn test_nan() {
let nan: f32 = f32::NAN;
// This will fail if the path isn't converted to verbatim.
path.push("a");
fs::create_dir(&path).unwrap();
+
+ // #90940: Ensure an empty path returns the "Not Found" error.
+ let path = Path::new("");
+ assert_eq!(path.canonicalize().unwrap_err().kind(), crate::io::ErrorKind::NotFound);
}
/// originate from the OS itself. The `error` argument is an arbitrary
/// payload which will be contained in this [`Error`].
///
+ /// If no extra payload is required, use the `From` conversion from
+ /// `ErrorKind`.
+ ///
/// # Examples
///
/// ```
///
/// // errors can also be created from other errors
/// let custom_error2 = Error::new(ErrorKind::Interrupted, custom_error);
+ ///
+ /// // creating an error without payload
+ /// let eof_error = Error::from(ErrorKind::UnexpectedEof);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new<E>(kind: ErrorKind, error: E) -> Error
/// {
/// let result = match IntoIterator::into_iter(iterator) {
/// mut iter => loop {
-/// let next;
/// match iter.next() {
-/// Some(val) => next = val,
/// None => break,
+/// Some(loop_variable) => { code(); },
/// };
-/// let loop_variable = next;
-/// let () = { code(); };
/// },
/// };
/// result
#![feature(exhaustive_patterns)]
#![feature(extend_one)]
#![feature(fn_traits)]
+#![feature(float_minimum_maximum)]
#![feature(format_args_nl)]
#![feature(gen_future)]
#![feature(generator_trait)]
/// * [`Clone`] \(Note that this will not defer to `T`'s `Clone` implementation if it exists!)
/// * [`Deref`]
/// * [`Borrow`]
-/// * [`Pointer`]
+/// * [`fmt::Pointer`]
///
/// [`Deref`]: ops::Deref
/// [`Borrow`]: borrow::Borrow
-/// [`Pointer`]: fmt::Pointer
///
/// `&mut T` references get all of the above except `Copy` and `Clone` (to prevent creating
/// multiple simultaneous mutable borrows), plus the following, regardless of the type of its
/// The following traits are implemented on `&T` references if the underlying `T` also implements
/// that trait:
///
-/// * All the traits in [`std::fmt`] except [`Pointer`] and [`fmt::Write`]
+/// * All the traits in [`std::fmt`] except [`fmt::Pointer`] (which is implemented regardless of the type of its referent) and [`fmt::Write`]
/// * [`PartialOrd`]
/// * [`Ord`]
/// * [`PartialEq`]
/// * [`Fn`] \(in addition, `&T` references get [`FnMut`] and [`FnOnce`] if `T: Fn`)
/// * [`Hash`]
/// * [`ToSocketAddrs`]
+/// * [`Send`] \(`&T` references also require <code>T: [Sync]</code>)
///
/// [`std::fmt`]: fmt
-/// ['Pointer`]: fmt::Pointer
/// [`Hash`]: hash::Hash
#[doc = concat!("[`ToSocketAddrs`]: ", include_str!("../primitive_docs/net_tosocketaddrs.md"))]
///
/// * [`ExactSizeIterator`]
/// * [`FusedIterator`]
/// * [`TrustedLen`]
-/// * [`Send`] \(note that `&T` references only get `Send` if <code>T: [Sync]</code>)
/// * [`io::Write`]
/// * [`Read`]
/// * [`Seek`]
#[test]
fn test_interior_nul_in_arg_is_error() {
- match Command::new("echo").arg("has-some-\0\0s-inside").spawn() {
+ match Command::new("rustc").arg("has-some-\0\0s-inside").spawn() {
Err(e) => assert_eq!(e.kind(), ErrorKind::InvalidInput),
Ok(_) => panic!(),
}
#[test]
fn test_interior_nul_in_args_is_error() {
- match Command::new("echo").args(&["has-some-\0\0s-inside"]).spawn() {
+ match Command::new("rustc").args(&["has-some-\0\0s-inside"]).spawn() {
Err(e) => assert_eq!(e.kind(), ErrorKind::InvalidInput),
Ok(_) => panic!(),
}
#[test]
fn test_interior_nul_in_current_dir_is_error() {
- match Command::new("echo").current_dir("has-some-\0\0s-inside").spawn() {
+ match Command::new("rustc").current_dir("has-some-\0\0s-inside").spawn() {
Err(e) => assert_eq!(e.kind(), ErrorKind::InvalidInput),
Ok(_) => panic!(),
}
return match err.raw_os_error() {
// when file offset + max_length > u64::MAX
Some(EOVERFLOW) => CopyResult::Fallback(written),
- Some(ENOSYS | EXDEV | EINVAL | EPERM | EOPNOTSUPP | EBADF) => {
+ Some(ENOSYS | EXDEV | EINVAL | EPERM | EOPNOTSUPP | EBADF) if written == 0 => {
// Try fallback io::copy if either:
// - Kernel version is < 4.5 (ENOSYS¹)
// - Files are mounted on different fs (EXDEV)
// - copy_file_range file is immutable or syscall is blocked by seccomp¹ (EPERM)
// - copy_file_range cannot be used with pipes or device nodes (EINVAL)
// - the writer fd was opened with O_APPEND (EBADF²)
+ // and no bytes were written successfully yet. (All these errnos should
+ // not be returned if something was already written, but they happen in
+ // the wild, see #91152.)
//
// ¹ these cases should be detected by the initial probe but we handle them here
// anyway in case syscall interception changes during runtime
// ² actually invalid file descriptors would cause this too, but in that case
// the fallback code path is expected to encounter the same error again
- assert_eq!(written, 0);
CopyResult::Fallback(0)
}
_ => CopyResult::Error(err, written),
lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
) -> BOOL;
pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL;
+ pub fn GetWindowsDirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT;
}
}
}
pub fn LeaveCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
pub fn DeleteCriticalSection(CriticalSection: *mut CRITICAL_SECTION);
+ pub fn GetSystemDirectoryW(lpBuffer: LPWSTR, uSize: UINT) -> UINT;
pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
pub fn SetFileAttributesW(lpFileName: LPCWSTR, dwFileAttributes: DWORD) -> BOOL;
pub fn SetLastError(dwErrCode: DWORD);
use super::{c, fill_utf16_buf, to_u16s};
-use crate::ffi::OsStr;
+use crate::ffi::{OsStr, OsString};
use crate::io;
use crate::mem;
-use crate::path::Path;
-use crate::path::Prefix;
+use crate::path::{Path, PathBuf, Prefix};
use crate::ptr;
#[cfg(test)]
b == b'\\'
}
+/// Returns true if `path` looks like a lone filename.
+pub(crate) fn is_file_name(path: &OsStr) -> bool {
+ !path.bytes().iter().copied().any(is_sep_byte)
+}
+pub(crate) fn has_trailing_slash(path: &OsStr) -> bool {
+ let is_verbatim = path.bytes().starts_with(br"\\?\");
+ let is_separator = if is_verbatim { is_verbatim_sep } else { is_sep_byte };
+ if let Some(&c) = path.bytes().last() { is_separator(c) } else { false }
+}
+
+/// Appends a suffix to a path.
+///
+/// Can be used to append an extension without removing an existing extension.
+pub(crate) fn append_suffix(path: PathBuf, suffix: &OsStr) -> PathBuf {
+ let mut path = OsString::from(path);
+ path.push(suffix);
+ path.into()
+}
+
pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
use Prefix::{DeviceNS, Disk, Verbatim, VerbatimDisk, VerbatimUNC, UNC};
const UNC_PREFIX: &[u16] = &[SEP, SEP, QUERY, SEP, U, N, C, SEP];
let mut path = to_u16s(path)?;
- if path.starts_with(VERBATIM_PREFIX) || path.starts_with(NT_PREFIX) {
- // Early return for paths that are already verbatim.
+ if path.starts_with(VERBATIM_PREFIX) || path.starts_with(NT_PREFIX) || path == &[0] {
+ // Early return for paths that are already verbatim or empty.
return Ok(path);
} else if path.len() < LEGACY_MAX_PATH {
// Early return if an absolute path is less < 260 UTF-16 code units.
// Make sure opening a drive will work.
check("Z:", "Z:");
- // An empty path or a path that contains null are not valid paths.
- assert!(maybe_verbatim(Path::new("")).is_err());
+ // A path that contains null is not a valid path.
assert!(maybe_verbatim(Path::new("\0")).is_err());
}
use crate::collections::BTreeMap;
use crate::convert::{TryFrom, TryInto};
use crate::env;
-use crate::env::split_paths;
+use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX};
use crate::ffi::{OsStr, OsString};
use crate::fmt;
-use crate::fs;
use crate::io::{self, Error, ErrorKind};
use crate::mem;
use crate::num::NonZeroI32;
-use crate::os::windows::ffi::OsStrExt;
+use crate::os::windows::ffi::{OsStrExt, OsStringExt};
use crate::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle};
-use crate::path::Path;
+use crate::path::{Path, PathBuf};
use crate::ptr;
use crate::sys::c;
use crate::sys::c::NonZeroDWORD;
-use crate::sys::cvt;
use crate::sys::fs::{File, OpenOptions};
use crate::sys::handle::Handle;
+use crate::sys::path;
use crate::sys::pipe::{self, AnonPipe};
use crate::sys::stdio;
+use crate::sys::{cvt, to_u16s};
use crate::sys_common::mutex::StaticMutex;
use crate::sys_common::process::{CommandEnv, CommandEnvs};
use crate::sys_common::{AsInner, IntoInner};
needs_stdin: bool,
) -> io::Result<(Process, StdioPipes)> {
let maybe_env = self.env.capture_if_changed();
- // To have the spawning semantics of unix/windows stay the same, we need
- // to read the *child's* PATH if one is provided. See #15149 for more
- // details.
- let program = maybe_env.as_ref().and_then(|env| {
- if let Some(v) = env.get(&EnvKey::new("PATH")) {
- // Split the value and test each path to see if the
- // program exists.
- for path in split_paths(&v) {
- let path = path
- .join(self.program.to_str().unwrap())
- .with_extension(env::consts::EXE_EXTENSION);
- if fs::metadata(&path).is_ok() {
- return Some(path.into_os_string());
- }
- }
- }
- None
- });
let mut si = zeroed_startupinfo();
si.cb = mem::size_of::<c::STARTUPINFO>() as c::DWORD;
si.dwFlags = c::STARTF_USESTDHANDLES;
- let program = program.as_ref().unwrap_or(&self.program);
- let mut cmd_str = make_command_line(program, &self.args, self.force_quotes_enabled)?;
+ let child_paths = if let Some(env) = maybe_env.as_ref() {
+ env.get(&EnvKey::new("PATH")).map(|s| s.as_os_str())
+ } else {
+ None
+ };
+ let program = resolve_exe(&self.program, child_paths)?;
+ let mut cmd_str =
+ make_command_line(program.as_os_str(), &self.args, self.force_quotes_enabled)?;
cmd_str.push(0); // add null terminator
// stolen from the libuv code.
si.hStdOutput = stdout.as_raw_handle();
si.hStdError = stderr.as_raw_handle();
+ let program = to_u16s(&program)?;
unsafe {
cvt(c::CreateProcessW(
- ptr::null(),
+ program.as_ptr(),
cmd_str.as_mut_ptr(),
ptr::null_mut(),
ptr::null_mut(),
}
}
+// Resolve `exe_path` to the executable name.
+//
+// * If the path is simply a file name then use the paths given by `search_paths` to find the executable.
+// * Otherwise use the `exe_path` as given.
+//
+// This function may also append `.exe` to the name. The rationale for doing so is as follows:
+//
+// It is a very strong convention that Windows executables have the `exe` extension.
+// In Rust, it is common to omit this extension.
+// Therefore this functions first assumes `.exe` was intended.
+// It falls back to the plain file name if a full path is given and the extension is omitted
+// or if only a file name is given and it already contains an extension.
+fn resolve_exe<'a>(exe_path: &'a OsStr, child_paths: Option<&OsStr>) -> io::Result<PathBuf> {
+ // Early return if there is no filename.
+ if exe_path.is_empty() || path::has_trailing_slash(exe_path) {
+ return Err(io::Error::new_const(
+ io::ErrorKind::InvalidInput,
+ &"program path has no file name",
+ ));
+ }
+ // Test if the file name has the `exe` extension.
+ // This does a case-insensitive `ends_with`.
+ let has_exe_suffix = if exe_path.len() >= EXE_SUFFIX.len() {
+ exe_path.bytes()[exe_path.len() - EXE_SUFFIX.len()..]
+ .eq_ignore_ascii_case(EXE_SUFFIX.as_bytes())
+ } else {
+ false
+ };
+
+ // If `exe_path` is an absolute path or a sub-path then don't search `PATH` for it.
+ if !path::is_file_name(exe_path) {
+ if has_exe_suffix {
+ // The application name is a path to a `.exe` file.
+ // Let `CreateProcessW` figure out if it exists or not.
+ return Ok(exe_path.into());
+ }
+ let mut path = PathBuf::from(exe_path);
+
+ // Append `.exe` if not already there.
+ path = path::append_suffix(path, EXE_SUFFIX.as_ref());
+ if path.try_exists().unwrap_or(false) {
+ return Ok(path);
+ } else {
+ // It's ok to use `set_extension` here because the intent is to
+ // remove the extension that was just added.
+ path.set_extension("");
+ return Ok(path);
+ }
+ } else {
+ ensure_no_nuls(exe_path)?;
+ // From the `CreateProcessW` docs:
+ // > If the file name does not contain an extension, .exe is appended.
+ // Note that this rule only applies when searching paths.
+ let has_extension = exe_path.bytes().contains(&b'.');
+
+ // Search the directories given by `search_paths`.
+ let result = search_paths(child_paths, |mut path| {
+ path.push(&exe_path);
+ if !has_extension {
+ path.set_extension(EXE_EXTENSION);
+ }
+ if let Ok(true) = path.try_exists() { Some(path) } else { None }
+ });
+ if let Some(path) = result {
+ return Ok(path);
+ }
+ }
+ // If we get here then the executable cannot be found.
+ Err(io::Error::new_const(io::ErrorKind::NotFound, &"program not found"))
+}
+
+// Calls `f` for every path that should be used to find an executable.
+// Returns once `f` returns the path to an executable or all paths have been searched.
+fn search_paths<F>(child_paths: Option<&OsStr>, mut f: F) -> Option<PathBuf>
+where
+ F: FnMut(PathBuf) -> Option<PathBuf>,
+{
+ // 1. Child paths
+ // This is for consistency with Rust's historic behaviour.
+ if let Some(paths) = child_paths {
+ for path in env::split_paths(paths).filter(|p| !p.as_os_str().is_empty()) {
+ if let Some(path) = f(path) {
+ return Some(path);
+ }
+ }
+ }
+
+ // 2. Application path
+ if let Ok(mut app_path) = env::current_exe() {
+ app_path.pop();
+ if let Some(path) = f(app_path) {
+ return Some(path);
+ }
+ }
+
+ // 3 & 4. System paths
+ // SAFETY: This uses `fill_utf16_buf` to safely call the OS functions.
+ unsafe {
+ if let Ok(Some(path)) = super::fill_utf16_buf(
+ |buf, size| c::GetSystemDirectoryW(buf, size),
+ |buf| f(PathBuf::from(OsString::from_wide(buf))),
+ ) {
+ return Some(path);
+ }
+ #[cfg(not(target_vendor = "uwp"))]
+ {
+ if let Ok(Some(path)) = super::fill_utf16_buf(
+ |buf, size| c::GetWindowsDirectoryW(buf, size),
+ |buf| f(PathBuf::from(OsString::from_wide(buf))),
+ ) {
+ return Some(path);
+ }
+ }
+ }
+
+ // 5. Parent paths
+ if let Some(parent_paths) = env::var_os("PATH") {
+ for path in env::split_paths(&parent_paths).filter(|p| !p.as_os_str().is_empty()) {
+ if let Some(path) = f(path) {
+ return Some(path);
+ }
+ }
+ }
+ None
+}
+
impl Stdio {
fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option<AnonPipe>) -> io::Result<Handle> {
match *self {
}
}
}
+
+// UWP applications run in a restricted environment which means this test may not work.
+#[cfg(not(target_vendor = "uwp"))]
+#[test]
+fn windows_exe_resolver() {
+ use super::resolve_exe;
+ use crate::io;
+
+ // Test a full path, with and without the `exe` extension.
+ let mut current_exe = env::current_exe().unwrap();
+ assert!(resolve_exe(current_exe.as_ref(), None).is_ok());
+ current_exe.set_extension("");
+ assert!(resolve_exe(current_exe.as_ref(), None).is_ok());
+
+ // Test lone file names.
+ assert!(resolve_exe(OsStr::new("cmd"), None).is_ok());
+ assert!(resolve_exe(OsStr::new("cmd.exe"), None).is_ok());
+ assert!(resolve_exe(OsStr::new("cmd.EXE"), None).is_ok());
+ assert!(resolve_exe(OsStr::new("fc"), None).is_ok());
+
+ // Invalid file names should return InvalidInput.
+ assert_eq!(resolve_exe(OsStr::new(""), None).unwrap_err().kind(), io::ErrorKind::InvalidInput);
+ assert_eq!(
+ resolve_exe(OsStr::new("\0"), None).unwrap_err().kind(),
+ io::ErrorKind::InvalidInput
+ );
+ // Trailing slash, therefore there's no file name component.
+ assert_eq!(
+ resolve_exe(OsStr::new(r"C:\Path\to\"), None).unwrap_err().kind(),
+ io::ErrorKind::InvalidInput
+ );
+
+ /*
+ Some of the following tests may need to be changed if you are deliberately
+ changing the behaviour of `resolve_exe`.
+ */
+
+ let paths = env::var_os("PATH").unwrap();
+ env::set_var("PATH", "");
+
+ assert_eq!(resolve_exe(OsStr::new("rustc"), None).unwrap_err().kind(), io::ErrorKind::NotFound);
+
+ let child_paths = Some(paths.as_os_str());
+ assert!(resolve_exe(OsStr::new("rustc"), child_paths).is_ok());
+
+ // The resolver looks in system directories even when `PATH` is empty.
+ assert!(resolve_exe(OsStr::new("cmd.exe"), None).is_ok());
+
+ // The application's directory is also searched.
+ let current_exe = env::current_exe().unwrap();
+ assert!(resolve_exe(current_exe.file_name().unwrap().as_ref(), None).is_ok());
+}
#[inline]
fn next(&mut self) -> Option<CodePoint> {
- next_code_point(&mut self.bytes).map(|c| CodePoint { value: c })
+ // SAFETY: `self.bytes` has been created from a WTF-8 string
+ unsafe { next_code_point(&mut self.bytes).map(|c| CodePoint { value: c }) }
}
#[inline]
#[cfg_attr(not(windows), inline)] // see comments below
unsafe fn __getit() -> $crate::option::Option<&'static $t> {
const _REQUIRE_UNSTABLE: () = $crate::thread::require_unstable_const_init_thread_local();
+ const INIT_EXPR: $t = $init;
// wasm without atomics maps directly to `static mut`, and dtors
// aren't implemented because thread dtors aren't really a thing
// block.
#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))]
{
- static mut VAL: $t = $init;
+ static mut VAL: $t = INIT_EXPR;
Some(&VAL)
}
not(all(target_family = "wasm", not(target_feature = "atomics"))),
))]
{
+ #[thread_local]
+ static mut VAL: $t = INIT_EXPR;
+
// If a dtor isn't needed we can do something "very raw" and
// just get going.
if !$crate::mem::needs_drop::<$t>() {
- #[thread_local]
- static mut VAL: $t = $init;
unsafe {
return Some(&VAL)
}
}
- #[thread_local]
- static mut VAL: $t = $init;
// 0 == dtor not registered
// 1 == dtor registered, dtor not run
// 2 == dtor registered and is running or has run
))]
{
#[inline]
- const fn __init() -> $t { $init }
+ const fn __init() -> $t { INIT_EXPR }
static __KEY: $crate::thread::__OsLocalKeyInner<$t> =
$crate::thread::__OsLocalKeyInner::new();
#[allow(unused_unsafe)]
-Subproject commit 815d55c610dab39e92e7c83bf5fd4b7a020b4d46
+Subproject commit cfba59fccd90b3b52a614120834320f764ab08d1
raise Exception("{} not found".format(vendor_dir))
if self.use_vendored_sources:
+ config = ("[source.crates-io]\n"
+ "replace-with = 'vendored-sources'\n"
+ "registry = 'https://example.com'\n"
+ "\n"
+ "[source.vendored-sources]\n"
+ "directory = '{}/vendor'\n"
+ .format(self.rust_root))
if not os.path.exists('.cargo'):
os.makedirs('.cargo')
- with output('.cargo/config') as cargo_config:
- cargo_config.write(
- "[source.crates-io]\n"
- "replace-with = 'vendored-sources'\n"
- "registry = 'https://example.com'\n"
- "\n"
- "[source.vendored-sources]\n"
- "directory = '{}/vendor'\n"
- .format(self.rust_root))
+ with output('.cargo/config') as cargo_config:
+ cargo_config.write(config)
+ else:
+ print('info: using vendored source, but .cargo/config is already present.')
+ print(' Reusing the current configuration file. But you may want to '
+ 'configure vendoring like this:')
+ print(config)
else:
if os.path.exists('.cargo'):
shutil.rmtree('.cargo')
-Subproject commit 5c5dbc5b196c9564422b3193264f3288d2a051ce
+Subproject commit a5e0c5b2c5f9054be3b961aea2c7edfeea591de8
-Subproject commit 27f4a84d3852e9416cae5861254fa53a825c56bd
+Subproject commit 8e0ec8c77d8b28b86159fdee9d33a758225ecf9c
-Subproject commit 51739471276b1776dea27cf562b974ef07e24685
+Subproject commit 8c395bdd8073deb20ca67e1ed4b14a3a7e315a37
-Subproject commit a01d151a7250a540a9cb7ccce5956f020c677c21
+Subproject commit c0f222da23568477155991d391c9ce918e381351
-Subproject commit e9d45342d7a6c1def4731f1782d87ea317ba30c3
+Subproject commit 43f82530210b83cf888282b207ed13d5893da9b2
-Subproject commit 196ef69aa68f2cef44f37566ee7db37daf00301b
+Subproject commit a2fc9635029c04e692474965a6606f8e286d539a
$ rustdoc src/lib.rs -Z unstable-options --show-coverage
```
+It generates something like this:
+
+```bash
++-------------------------------------+------------+------------+------------+------------+
+| File | Documented | Percentage | Examples | Percentage |
++-------------------------------------+------------+------------+------------+------------+
+| lib.rs | 4 | 100.0% | 1 | 25.0% |
++-------------------------------------+------------+------------+------------+------------+
+| Total | 4 | 100.0% | 1 | 25.0% |
++-------------------------------------+------------+------------+------------+------------+
+```
+
If you want to determine how many items in your crate are documented, pass this flag to rustdoc.
When it receives this flag, it will count the public items in your crate that have documentation,
and print out the counts and a percentage instead of generating docs.
Public items that are not documented can be seen with the built-in `missing_docs` lint. Private
items that are not documented can be seen with Clippy's `missing_docs_in_private_items` lint.
-### `-w`/`--output-format`: output format
+Calculating code examples follows these rules:
-When using
-[`--show-coverage`](https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#--show-coverage-get-statistics-about-code-documentation-coverage),
-passing `--output-format json` will display the coverage information in JSON format. For example,
-here is the JSON for a file with one documented item and one undocumented item:
+1. These items aren't accounted by default:
+ * struct/union field
+ * enum variant
+ * constant
+ * static
+ * typedef
+2. If one of the previously listed items has a code example, then it'll be counted.
+
+#### JSON output
+
+When using `--output-format json` with this option, it will display the coverage information in
+JSON format. For example, here is the JSON for a file with one documented item and one
+undocumented item:
```rust
/// This item has documentation
Note that the third item is the crate root, which in this case is undocumented.
-When not using `--show-coverage`, `--output-format json` emits documentation in the experimental
+### `-w`/`--output-format`: output format
+
+`--output-format json` emits documentation in the experimental
[JSON format](https://github.com/rust-lang/rfcs/pull/2963). `--output-format html` has no effect,
and is also accepted on stable toolchains.
+It can also be used with `--show-coverage`. Take a look at its
+[documentation](#--show-coverage-get-statistics-about-code-documentation-coverage) for more
+information.
+
### `--enable-per-target-ignores`: allow `ignore-foo` style filters for doctests
Using this flag looks like this:
Another use case would be to run a test inside an emulator, or through a Virtual Machine.
-### `--show-coverage`: get statistics about code documentation coverage
-
-This option allows you to get a nice overview over your code documentation coverage, including both
-doc-comments and code examples in the doc-comments. Example:
-
-```bash
-$ rustdoc src/lib.rs -Z unstable-options --show-coverage
-+-------------------------------------+------------+------------+------------+------------+
-| File | Documented | Percentage | Examples | Percentage |
-+-------------------------------------+------------+------------+------------+------------+
-| lib.rs | 4 | 100.0% | 1 | 25.0% |
-+-------------------------------------+------------+------------+------------+------------+
-| Total | 4 | 100.0% | 1 | 25.0% |
-+-------------------------------------+------------+------------+------------+------------+
-```
-
-You can also use this option with the `--output-format` one:
-
-```bash
-$ rustdoc src/lib.rs -Z unstable-options --show-coverage --output-format json
-{"lib.rs":{"total":4,"with_docs":4,"total_examples":4,"with_examples":1}}
-```
-
-Calculating code examples follows these rules:
-
-1. These items aren't accounted by default:
- * struct/union field
- * enum variant
- * constant
- * static
- * typedef
-2. If one of the previously listed items has a code example, then it'll be counted.
-
### `--with-examples`: include examples of uses of items as documentation
This option, combined with `--scrape-examples-target-crate` and
--- /dev/null
+# `inline_const_pat`
+
+The tracking issue for this feature is: [#76001]
+
+See also [`inline_const`](inline-const.md)
+
+------
+
+This feature allows you to use inline constant expressions in pattern position:
+
+```rust
+#![feature(inline_const_pat)]
+
+const fn one() -> i32 { 1 }
+
+let some_int = 3;
+match some_int {
+ const { 1 + 2 } => println!("Matched 1 + 2"),
+ const { one() } => println!("Matched const fn returning 1"),
+ _ => println!("Didn't match anything :("),
+}
+```
+
+[#76001]: https://github.com/rust-lang/rust/issues/76001
The tracking issue for this feature is: [#76001]
+See also [`inline_const_pat`](inline-const-pat.md)
+
------
This feature allows you to use inline constant expressions. For example, you can
}
```
-You can also use inline constant expressions in patterns:
-
-```rust
-#![feature(inline_const)]
-
-const fn one() -> i32 { 1 }
-
-let some_int = 3;
-match some_int {
- const { 1 + 2 } => println!("Matched 1 + 2"),
- const { one() } => println!("Matched const fn returning 1"),
- _ => println!("Didn't match anything :("),
-}
-```
-
[#76001]: https://github.com/rust-lang/rust/issues/76001
let asyncness = cx.tcx.asyncness(did);
let predicates = cx.tcx.predicates_of(did);
let (generics, decl) = clean::enter_impl_trait(cx, |cx| {
+ // NOTE: generics need to be cleaned before the decl!
((cx.tcx.generics_of(did), predicates).clean(cx), (did, sig).clean(cx))
});
clean::Function {
match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.sess()) {
LoadedMacro::MacroDef(item_def, _) => {
if let ast::ItemKind::MacroDef(ref def) = item_def.kind {
+ let vis = cx.tcx.visibility(import_def_id.unwrap_or(def_id)).clean(cx);
clean::MacroItem(clean::Macro {
- source: utils::display_macro_source(
- cx,
- name,
- def,
- def_id,
- cx.tcx.visibility(import_def_id.unwrap_or(def_id)),
- ),
+ source: utils::display_macro_source(cx, name, def, def_id, vis),
})
} else {
unreachable!()
};
GenericBound::TraitBound(
- PolyTrait { trait_: (trait_ref, &*bindings).clean(cx), generic_params: vec![] },
+ PolyTrait {
+ trait_: (trait_ref, &bindings[..]).clean(cx),
+ generic_params: vec![],
+ },
hir::TraitBoundModifier::None,
)
}
// scans them first.
fn is_impl_trait(param: &hir::GenericParam<'_>) -> bool {
match param.kind {
- hir::GenericParamKind::Type { synthetic, .. } => {
- synthetic == Some(hir::SyntheticTyParamKind::ImplTrait)
- }
+ hir::GenericParamKind::Type { synthetic, .. } => synthetic,
_ => false,
}
}
assert_eq!(param.index, 0);
return None;
}
- if synthetic == Some(hir::SyntheticTyParamKind::ImplTrait) {
+ if synthetic {
impl_trait.insert(param.index.into(), vec![]);
return None;
}
impl<'a> Clean<Function> for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::BodyId) {
fn clean(&self, cx: &mut DocContext<'_>) -> Function {
- let (generics, decl) =
- enter_impl_trait(cx, |cx| (self.1.clean(cx), (&*self.0.decl, self.2).clean(cx)));
+ let (generics, decl) = enter_impl_trait(cx, |cx| {
+ // NOTE: generics must be cleaned before args
+ let generics = self.1.clean(cx);
+ let args = (self.0.decl.inputs, self.2).clean(cx);
+ let decl = clean_fn_decl_with_args(cx, self.0.decl, args);
+ (generics, decl)
+ });
Function { decl, generics, header: self.0.header }
}
}
}
}
-impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl<'a>, A)
-where
- (&'a [hir::Ty<'a>], A): Clean<Arguments>,
-{
- fn clean(&self, cx: &mut DocContext<'_>) -> FnDecl {
- FnDecl {
- inputs: (self.0.inputs, self.1).clean(cx),
- output: self.0.output.clean(cx),
- c_variadic: self.0.c_variadic,
- }
- }
+fn clean_fn_decl_with_args(
+ cx: &mut DocContext<'_>,
+ decl: &hir::FnDecl<'_>,
+ args: Arguments,
+) -> FnDecl {
+ FnDecl { inputs: args, output: decl.output.clean(cx), c_variadic: decl.c_variadic }
}
impl<'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
}
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => {
let (generics, decl) = enter_impl_trait(cx, |cx| {
- (self.generics.clean(cx), (sig.decl, names).clean(cx))
+ // NOTE: generics must be cleaned before args
+ let generics = self.generics.clean(cx);
+ let args = (sig.decl.inputs, names).clean(cx);
+ let decl = clean_fn_decl_with_args(cx, sig.decl, args);
+ (generics, decl)
});
let mut t = Function { header: sig.header, decl, generics };
if t.header.constness == hir::Constness::Const
impl Clean<Item> for hir::FieldDef<'_> {
fn clean(&self, cx: &mut DocContext<'_>) -> Item {
- let what_rustc_thinks = Item::from_hir_id_and_parts(
- self.hir_id,
- Some(self.ident.name),
- StructFieldItem(self.ty.clean(cx)),
- cx,
- );
- // Don't show `pub` for fields on enum variants; they are always public
- Item { visibility: self.vis.clean(cx), ..what_rustc_thinks }
+ let def_id = cx.tcx.hir().local_def_id(self.hir_id).to_def_id();
+ clean_field(def_id, self.ident.name, self.ty.clean(cx), cx)
}
}
impl Clean<Item> for ty::FieldDef {
fn clean(&self, cx: &mut DocContext<'_>) -> Item {
- let what_rustc_thinks = Item::from_def_id_and_parts(
- self.did,
- Some(self.ident.name),
- StructFieldItem(cx.tcx.type_of(self.did).clean(cx)),
- cx,
- );
- // Don't show `pub` for fields on enum variants; they are always public
- Item { visibility: self.vis.clean(cx), ..what_rustc_thinks }
+ clean_field(self.did, self.ident.name, cx.tcx.type_of(self.did).clean(cx), cx)
}
}
-impl Clean<Visibility> for hir::Visibility<'_> {
- fn clean(&self, cx: &mut DocContext<'_>) -> Visibility {
- match self.node {
- hir::VisibilityKind::Public => Visibility::Public,
- hir::VisibilityKind::Inherited => Visibility::Inherited,
- hir::VisibilityKind::Crate(_) => {
- let krate = DefId::local(CRATE_DEF_INDEX);
- Visibility::Restricted(krate)
- }
- hir::VisibilityKind::Restricted { ref path, .. } => {
- let path = path.clean(cx);
- let did = register_res(cx, path.res);
- Visibility::Restricted(did)
- }
- }
+fn clean_field(def_id: DefId, name: Symbol, ty: Type, cx: &mut DocContext<'_>) -> Item {
+ let what_rustc_thinks =
+ Item::from_def_id_and_parts(def_id, Some(name), StructFieldItem(ty), cx);
+ if is_field_vis_inherited(cx.tcx, def_id) {
+ // Variant fields inherit their enum's visibility.
+ Item { visibility: Visibility::Inherited, ..what_rustc_thinks }
+ } else {
+ what_rustc_thinks
+ }
+}
+
+fn is_field_vis_inherited(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
+ let parent = tcx
+ .parent(def_id)
+ .expect("is_field_vis_inherited can only be called on struct or variant fields");
+ match tcx.def_kind(parent) {
+ DefKind::Struct | DefKind::Union => false,
+ DefKind::Variant => true,
+ // FIXME: what about DefKind::Ctor?
+ parent_kind => panic!("unexpected parent kind: {:?}", parent_kind),
}
}
// NOTE: this is not quite right: `ty` uses `Invisible` to mean 'private',
// while rustdoc really does mean inherited. That means that for enum variants, such as
// `pub enum E { V }`, `V` will be marked as `Public` by `ty`, but as `Inherited` by rustdoc.
- // This is the main reason `impl Clean for hir::Visibility` still exists; various parts of clean
- // override `tcx.visibility` explicitly to make sure this distinction is captured.
+ // Various parts of clean override `tcx.visibility` explicitly to make sure this distinction is captured.
ty::Visibility::Invisible => Visibility::Inherited,
ty::Visibility::Restricted(module) => Visibility::Restricted(module),
}
fn clean(&self, cx: &mut DocContext<'_>) -> Item {
let kind = match self.ctor_kind {
CtorKind::Const => Variant::CLike,
- CtorKind::Fn => Variant::Tuple(
- self.fields
- .iter()
- .map(|field| {
- let name = Some(field.ident.name);
- let kind = StructFieldItem(cx.tcx.type_of(field.did).clean(cx));
- let what_rustc_thinks =
- Item::from_def_id_and_parts(field.did, name, kind, cx);
- // don't show `pub` for fields, which are always public
- Item { visibility: Visibility::Inherited, ..what_rustc_thinks }
- })
- .collect(),
- ),
+ CtorKind::Fn => {
+ Variant::Tuple(self.fields.iter().map(|field| field.clean(cx)).collect())
+ }
CtorKind::Fictive => Variant::Struct(VariantStruct {
struct_type: CtorKind::Fictive,
fields_stripped: false,
- fields: self
- .fields
- .iter()
- .map(|field| {
- let name = Some(field.ident.name);
- let kind = StructFieldItem(cx.tcx.type_of(field.did).clean(cx));
- let what_rustc_thinks =
- Item::from_def_id_and_parts(field.did, name, kind, cx);
- // don't show `pub` for fields, which are always public
- Item { visibility: Visibility::Inherited, ..what_rustc_thinks }
- })
- .collect(),
+ fields: self.fields.iter().map(|field| field.clean(cx)).collect(),
}),
};
let what_rustc_thinks =
Item::from_def_id_and_parts(self.def_id, Some(self.ident.name), VariantItem(kind), cx);
- // don't show `pub` for fields, which are always public
+ // don't show `pub` for variants, which always inherit visibility
Item { visibility: Inherited, ..what_rustc_thinks }
}
}
impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl {
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
+ // NOTE: generics must be cleaned before args
let generic_params = self.generic_params.iter().map(|x| x.clean(cx)).collect();
- let decl = (self.decl, self.param_names).clean(cx);
+ let args = (self.decl.inputs, self.param_names).clean(cx);
+ let decl = clean_fn_decl_with_args(cx, self.decl, args);
(generic_params, decl)
});
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
ItemKind::Fn(ref sig, ref generics, body_id) => {
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
}
- ItemKind::Macro(ref macro_def) => MacroItem(Macro {
- source: display_macro_source(cx, name, macro_def, def_id, item.vis),
- }),
+ ItemKind::Macro(ref macro_def) => {
+ let ty_vis = cx.tcx.visibility(def_id).clean(cx);
+ MacroItem(Macro {
+ source: display_macro_source(cx, name, macro_def, def_id, ty_vis),
+ })
+ }
ItemKind::Trait(is_auto, unsafety, ref generics, bounds, item_ids) => {
let items = item_ids
.iter()
// this is the ID of the crate itself
let crate_def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
let attrs = cx.tcx.hir().attrs(krate.hir_id());
- let please_inline = cx.tcx.visibility(krate.def_id).is_public()
+ let ty_vis = cx.tcx.visibility(krate.def_id);
+ let please_inline = ty_vis.is_public()
&& attrs.iter().any(|a| {
a.has_name(sym::doc)
&& match a.meta_item_list() {
name: Some(name),
attrs: box attrs.clean(cx),
def_id: crate_def_id.into(),
- visibility: krate.vis.clean(cx),
+ visibility: ty_vis.clean(cx),
kind: box ExternCrateItem { src: orig_name },
cfg: attrs.cfg(cx.tcx, &cx.cache.hidden_cfg),
}]
let inline_attr = attrs.lists(sym::doc).get_word_attr(sym::inline);
let pub_underscore = visibility.is_public() && name == kw::Underscore;
let current_mod = cx.tcx.parent_module_from_def_id(import.def_id);
+
+ // The parent of the module in which this import resides. This
+ // is the same as `current_mod` if that's already the top
+ // level module.
let parent_mod = cx.tcx.parent_module_from_def_id(current_mod);
+ // This checks if the import can be seen from a higher level module.
+ // In other words, it checks if the visibility is the equivalent of
+ // `pub(super)` or higher. If the current module is the top level
+ // module, there isn't really a parent module, which makes the results
+ // meaningless. In this case, we make sure the answer is `false`.
+ let is_visible_from_parent_mod = visibility.is_accessible_from(parent_mod.to_def_id(), cx.tcx)
+ && !current_mod.is_top_level_module();
+
if pub_underscore {
if let Some(ref inline) = inline_attr {
rustc_errors::struct_span_err!(
// #[doc(no_inline)] attribute is present.
// Don't inline doc(hidden) imports so they can be stripped at a later stage.
let mut denied = !(visibility.is_public()
- || (cx.render_options.document_private
- && visibility.is_accessible_from(parent_mod.to_def_id(), cx.tcx)))
+ || (cx.render_options.document_private && is_visible_from_parent_mod))
|| pub_underscore
|| attrs.iter().any(|a| {
a.has_name(sym::doc)
let kind = match item.kind {
hir::ForeignItemKind::Fn(decl, names, ref generics) => {
let abi = cx.tcx.hir().get_foreign_abi(item.hir_id());
- let (generics, decl) =
- enter_impl_trait(cx, |cx| (generics.clean(cx), (decl, names).clean(cx)));
+ let (generics, decl) = enter_impl_trait(cx, |cx| {
+ // NOTE: generics must be cleaned before args
+ let generics = generics.clean(cx);
+ let args = (decl.inputs, names).clean(cx);
+ let decl = clean_fn_decl_with_args(cx, decl, args);
+ (generics, decl)
+ });
ForeignFunctionItem(Function {
decl,
generics,
#[derive(Clone, Debug)]
crate struct Crate {
crate module: Item,
- crate externs: Vec<ExternalCrate>,
crate primitives: ThinVec<(DefId, PrimitiveType)>,
/// Only here so that they can be filtered through the rustdoc passes.
crate external_traits: Rc<RefCell<FxHashMap<DefId, TraitWithExtraInfo>>>,
// `Crate` is frequently moved by-value. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
-rustc_data_structures::static_assert_size!(Crate, 104);
+rustc_data_structures::static_assert_size!(Crate, 80);
impl Crate {
crate fn name(&self, tcx: TyCtxt<'_>) -> Symbol {
/// kept separate because of issue #42760.
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
crate struct DocFragment {
- crate line: usize,
crate span: rustc_span::Span,
/// The module this doc-comment came from.
///
crate indent: usize,
}
+// `DocFragment` is used a lot. Make sure it doesn't unintentionally get bigger.
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+rustc_data_structures::static_assert_size!(DocFragment, 32);
+
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
crate enum DocFragmentKind {
/// A doc fragment created from a `///` or `//!` doc comment.
additional_attrs: Option<(&[ast::Attribute], DefId)>,
) -> Attributes {
let mut doc_strings: Vec<DocFragment> = vec![];
- let mut doc_line = 0;
fn update_need_backline(doc_strings: &mut Vec<DocFragment>) {
if let Some(prev) = doc_strings.last_mut() {
DocFragmentKind::RawDoc
};
- let line = doc_line;
- doc_line += value.as_str().lines().count();
let frag = DocFragment {
- line,
span: attr.span,
doc: value,
kind,
if self.doc_strings.is_empty() { None } else { Some(self.doc_strings.iter().collect()) }
}
- crate fn get_doc_aliases(&self) -> Box<[String]> {
+ crate fn get_doc_aliases(&self) -> Box<[Symbol]> {
let mut aliases = FxHashSet::default();
for attr in self.other_attrs.lists(sym::doc).filter(|a| a.has_name(sym::alias)) {
for l in values {
match l.literal().unwrap().kind {
ast::LitKind::Str(s, _) => {
- aliases.insert(s.as_str().to_string());
+ aliases.insert(s);
}
_ => unreachable!(),
}
}
} else {
- aliases.insert(attr.value_str().map(|s| s.to_string()).unwrap());
+ aliases.insert(attr.value_str().unwrap());
}
}
- aliases.into_iter().collect::<Vec<String>>().into()
+ aliases.into_iter().collect::<Vec<_>>().into()
}
}
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
crate enum GenericParamDefKind {
- Lifetime {
- outlives: Vec<Lifetime>,
- },
- Type {
- did: DefId,
- bounds: Vec<GenericBound>,
- default: Option<Box<Type>>,
- synthetic: Option<hir::SyntheticTyParamKind>,
- },
- Const {
- did: DefId,
- ty: Box<Type>,
- default: Option<Box<String>>,
- },
+ Lifetime { outlives: Vec<Lifetime> },
+ Type { did: DefId, bounds: Vec<GenericBound>, default: Option<Box<Type>>, synthetic: bool },
+ Const { did: DefId, ty: Box<Type>, default: Option<Box<String>> },
}
impl GenericParamDefKind {
crate fn is_synthetic_type_param(&self) -> bool {
match self.kind {
GenericParamDefKind::Lifetime { .. } | GenericParamDefKind::Const { .. } => false,
- GenericParamDefKind::Type { ref synthetic, .. } => synthetic.is_some(),
+ GenericParamDefKind::Type { synthetic, .. } => synthetic,
}
}
};
use crate::core::DocContext;
use crate::formats::item_type::ItemType;
+use crate::visit_lib::LibEmbargoVisitor;
use rustc_ast as ast;
use rustc_ast::tokenstream::TokenTree;
mod tests;
crate fn krate(cx: &mut DocContext<'_>) -> Crate {
- use crate::visit_lib::LibEmbargoVisitor;
-
let module = crate::visit_ast::RustdocVisitor::new(cx).visit();
- let mut externs = Vec::new();
for &cnum in cx.tcx.crates(()) {
- externs.push(ExternalCrate { crate_num: cnum });
// Analyze doc-reachability for extern items
LibEmbargoVisitor::new(cx).visit_lib(cnum);
}
}));
}
- Crate {
- module,
- externs,
- primitives,
- external_traits: cx.external_traits.clone(),
- collapsed: false,
- }
+ Crate { module, primitives, external_traits: cx.external_traits.clone(), collapsed: false }
}
fn external_generic_args(
name: Symbol,
def: &ast::MacroDef,
def_id: DefId,
- vis: impl Clean<Visibility>,
+ vis: Visibility,
) -> String {
let tts: Vec<_> = def.body.inner_tokens().into_trees().collect();
// Extract the spans of all matchers. They represent the "interface" of the macro.
if def.macro_rules {
format!("macro_rules! {} {{\n{}}}", name, render_macro_arms(matchers, ";"))
} else {
- let vis = vis.clean(cx);
-
if matchers.len() <= 1 {
format!(
"{}macro {}{} {{\n ...\n}}",
rustc_errors::FatalError.raise();
}
- let render_options = ctxt.render_options;
- let mut cache = ctxt.cache;
- krate = tcx.sess.time("create_format_cache", || cache.populate(krate, tcx, &render_options));
+ krate = tcx.sess.time("create_format_cache", || Cache::populate(&mut ctxt, krate));
// The main crate doc comments are always collapsed.
krate.collapsed = true;
- (krate, render_options, cache)
+ (krate, ctxt.render_options, ctxt.cache)
}
/// Due to <https://github.com/rust-lang/rust/pull/73566>,
#[derive(Clone, Debug, Serialize)]
crate struct ExternalHtml {
- /// Content that will be included inline in the <head> section of a
+ /// Content that will be included inline in the `<head>` section of a
/// rendered Markdown file or generated documentation
crate in_header: String,
- /// Content that will be included inline between <body> and the content of
+ /// Content that will be included inline between `<body>` and the content of
/// a rendered Markdown file or generated documentation
crate before_content: String,
- /// Content that will be included inline between the content and </body> of
+ /// Content that will be included inline between the content and `</body>` of
/// a rendered Markdown file or generated documentation
crate after_content: String,
}
use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::sym;
-use crate::clean::{self, ItemId, PrimitiveType};
-use crate::config::RenderOptions;
+use crate::clean::{self, ExternalCrate, ItemId, PrimitiveType};
+use crate::core::DocContext;
use crate::fold::DocFolder;
use crate::formats::item_type::ItemType;
use crate::formats::Impl;
/// Populates the `Cache` with more data. The returned `Crate` will be missing some data that was
/// in `krate` due to the data being moved into the `Cache`.
- crate fn populate(
- &mut self,
- mut krate: clean::Crate,
- tcx: TyCtxt<'_>,
- render_options: &RenderOptions,
- ) -> clean::Crate {
+ crate fn populate(cx: &mut DocContext<'_>, mut krate: clean::Crate) -> clean::Crate {
+ let tcx = cx.tcx;
+
// Crawl the crate to build various caches used for the output
- debug!(?self.crate_version);
- self.traits = krate.external_traits.take();
- let RenderOptions { extern_html_root_takes_precedence, output: dst, .. } = render_options;
+ debug!(?cx.cache.crate_version);
+ cx.cache.traits = krate.external_traits.take();
// Cache where all our extern crates are located
// FIXME: this part is specific to HTML so it'd be nice to remove it from the common code
- for &e in &krate.externs {
+ for &crate_num in cx.tcx.crates(()) {
+ let e = ExternalCrate { crate_num };
+
let name = e.name(tcx);
+ let render_options = &cx.render_options;
let extern_url =
render_options.extern_html_root_urls.get(&*name.as_str()).map(|u| &**u);
- let location = e.location(extern_url, *extern_html_root_takes_precedence, dst, tcx);
- self.extern_locations.insert(e.crate_num, location);
- self.external_paths.insert(e.def_id(), (vec![name.to_string()], ItemType::Module));
+ let extern_url_takes_precedence = render_options.extern_html_root_takes_precedence;
+ let dst = &render_options.output;
+ let location = e.location(extern_url, extern_url_takes_precedence, dst, tcx);
+ cx.cache.extern_locations.insert(e.crate_num, location);
+ cx.cache.external_paths.insert(e.def_id(), (vec![name.to_string()], ItemType::Module));
}
// FIXME: avoid this clone (requires implementing Default manually)
- self.primitive_locations = PrimitiveType::primitive_locations(tcx).clone();
- for (prim, &def_id) in &self.primitive_locations {
+ cx.cache.primitive_locations = PrimitiveType::primitive_locations(tcx).clone();
+ for (prim, &def_id) in &cx.cache.primitive_locations {
let crate_name = tcx.crate_name(def_id.krate);
// Recall that we only allow primitive modules to be at the root-level of the crate.
// If that restriction is ever lifted, this will have to include the relative paths instead.
- self.external_paths.insert(
+ cx.cache.external_paths.insert(
def_id,
(vec![crate_name.to_string(), prim.as_sym().to_string()], ItemType::Primitive),
);
}
- krate = CacheBuilder { tcx, cache: self }.fold_crate(krate);
+ krate = CacheBuilder { tcx, cache: &mut cx.cache }.fold_crate(krate);
- for (trait_did, dids, impl_) in self.orphan_trait_impls.drain(..) {
- if self.traits.contains_key(&trait_did) {
+ for (trait_did, dids, impl_) in cx.cache.orphan_trait_impls.drain(..) {
+ if cx.cache.traits.contains_key(&trait_did) {
for did in dids {
- self.impls.entry(did).or_default().push(impl_.clone());
+ cx.cache.impls.entry(did).or_default().push(impl_.clone());
}
}
}
}
fn get_entry(&mut self, key: &str) -> &mut (Vec<Event<'a>>, u16) {
- let new_id = self.footnotes.keys().count() + 1;
+ let new_id = self.footnotes.len() + 1;
let key = key.to_owned();
self.footnotes.entry(key).or_insert((Vec::new(), new_id as u16))
}
// Set up alias indexes.
for (i, item) in search_index.iter().enumerate() {
for alias in &item.aliases[..] {
- aliases.entry(alias.to_lowercase()).or_insert_with(Vec::new).push(i);
+ aliases.entry(alias.as_str().to_lowercase()).or_default().push(i);
}
}
crate parent: Option<DefId>,
crate parent_idx: Option<usize>,
crate search_type: Option<IndexItemFunctionType>,
- crate aliases: Box<[String]>,
+ crate aliases: Box<[Symbol]>,
}
/// A type used for the search index.
cx.derive_id(format!("{}.{}", ItemType::Variant, variant.name.as_ref().unwrap()));
write!(
w,
- "<div id=\"{id}\" class=\"variant small-section-header\">\
+ "<h3 id=\"{id}\" class=\"variant small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<code>{name}",
id = id,
}
w.write_str("</code>");
render_stability_since(w, variant, it, cx.tcx());
- w.write_str("</div>");
- document(w, cx, variant, Some(it), HeadingOffset::H3);
- document_non_exhaustive(w, variant);
+ w.write_str("</h3>");
use crate::clean::Variant;
if let Some((extra, fields)) = match *variant.kind {
variant.name.as_ref().unwrap()
));
write!(w, "<div class=\"sub-variant\" id=\"{id}\">", id = variant_id);
- write!(
- w,
- "<h3>{extra}Fields of <b>{name}</b></h3><div>",
- extra = extra,
- name = variant.name.as_ref().unwrap(),
- );
+ write!(w, "<h4>{extra}Fields</h4>", extra = extra,);
+ document_non_exhaustive(w, variant);
for field in fields {
match *field.kind {
clean::StrippedItem(box clean::StructFieldItem(_)) => {}
));
write!(
w,
- "<span id=\"{id}\" class=\"variant small-section-header\">\
+ "<div class=\"sub-variant-field\">\
+ <span id=\"{id}\" class=\"variant small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\
<code>{f}: {t}</code>\
</span>",
f = field.name.as_ref().unwrap(),
t = ty.print(cx)
);
- document(w, cx, field, Some(variant), HeadingOffset::H4);
+ document(w, cx, field, Some(variant), HeadingOffset::H5);
+ write!(w, "</div>");
}
_ => unreachable!(),
}
}
- w.write_str("</div></div>");
+ w.write_str("</div>");
}
+
+ document(w, cx, variant, Some(it), HeadingOffset::H4);
}
}
let def_id = it.def_id.expect_def_id();
div.item-list .out-of-band, span.since,
#source-sidebar, #sidebar-toggle,
details.rustdoc-toggle > summary::before,
-details.undocumented > summary::before,
div.impl-items > div:not(.docblock):not(.item-info),
.content ul.crate a.crate, a.srclink,
/* This selector is for the items listed in the "all items" page. */
left: 0;
top: 0;
bottom: 0;
- overflow: auto;
+ overflow-y: scroll;
}
/* Improve the scrollbar display on firefox */
text-decoration: none;
}
-.section-header a {
- color: inherit;
-}
-
.code-attribute {
font-weight: 300;
}
margin-right: 5px;
}
-.sub-variant, .sub-variant > h3 {
- margin-top: 0px !important;
- padding-top: 1px;
+h3.variant {
+ font-weight: 600;
+ font-size: 1.1em;
+ margin-bottom: 10px;
+ border-bottom: none;
}
-#main .sub-variant > h3 {
- font-size: 15px;
- margin-left: 25px;
- margin-bottom: 5px;
+.sub-variant h4 {
+ font-size: 1em;
+ font-weight: 400;
+ border-bottom: none;
+ margin-top: 0;
+ margin-bottom: 0;
}
-.sub-variant > div {
- margin-left: 20px;
- margin-bottom: 10px;
+.sub-variant {
+ margin-left: 24px;
+ margin-bottom: 40px;
}
-.sub-variant > div > span {
- display: block;
- position: relative;
+.sub-variant > .sub-variant-field {
+ margin-left: 24px;
}
.toggle-label {
cursor: pointer;
}
-details.rustdoc-toggle > summary, details.undocumented > summary {
+details.rustdoc-toggle > summary {
list-style: none;
}
details.rustdoc-toggle > summary::-webkit-details-marker,
-details.rustdoc-toggle > summary::marker,
-details.undocumented > summary::-webkit-details-marker,
-details.undocumented > summary::marker {
+details.rustdoc-toggle > summary::marker {
display: none;
}
top: 3px;
}
-.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before,
-.undocumented > details.rustdoc-toggle > summary:not(.hideme)::before {
+.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before {
position: absolute;
left: -24px;
}
position: absolute;
}
-details.rustdoc-toggle, details.undocumented {
+details.rustdoc-toggle {
position: relative;
}
content: "Collapse";
}
-details.undocumented > summary::before {
- padding-left: 17px;
- height: max(17px, 1.1em);
- background-repeat: no-repeat;
- background-position: top left;
- content: "Show hidden undocumented items";
- cursor: pointer;
- font-size: 16px;
- font-weight: 300;
- opacity: .5;
-}
-
-details.undocumented > summary:focus::before,
-details.undocumented > summary:hover::before {
- opacity: 1;
-}
-
-details.undocumented[open] > summary::before {
- padding-left: 17px;
- height: max(17px, 1.1em);
- background-repeat: no-repeat
- background-position: top left;
- content: "Hide undocumented items";
-}
-
/* Media Queries */
@media (min-width: 701px) {
/* Improve the scrollbar display on firefox */
* {
- scrollbar-color: #5c6773 transparent;
+ scrollbar-color: #5c6773 #24292f;
}
.sidebar {
- scrollbar-color: #5c6773 transparent;
+ scrollbar-color: #5c6773 #24292f;
}
/* Improve the scrollbar display on webkit-based browsers */
border: 1px solid #5c6773;
}
a {
+ color: #39AFD7;
+}
+a.srclink,
+a#toggle-all-docs,
+#source-sidebar a,
+pre.rust a,
+.sidebar a,
+.in-band a {
color: #c5c5c5;
}
+.search-results a {
+ color: #0096cf;
+}
body.source .example-wrap pre.rust a {
background: #333;
}
-.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow),
-.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
-#help a {
- color: #39AFD7;
-}
-
details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary::before,
details.undocumented > summary::before {
scrollbar-color: rgb(64, 65, 67) #717171;
}
.sidebar {
- scrollbar-color: rgba(32,34,37,.6) transparent;
+ scrollbar-color: rgba(32,34,37,.6) #5a5a5a;
}
/* Improve the scrollbar display on webkit-based browsers */
nav.main .separator {
border-color: #eee;
}
+
a {
- color: #ddd;
+ color: #D2991D;
}
-body.source .example-wrap pre.rust a {
- background: #333;
+a.srclink,
+a#toggle-all-docs,
+#source-sidebar a,
+pre.rust a,
+.sidebar a,
+.in-band a {
+ color: #ddd;
}
-
-.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow),
-.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
-#help a {
- color: #D2991D;
+.search-results a {
+ color: #ddd;
}
-
a.test-arrow {
color: #dedede;
}
+body.source .example-wrap pre.rust a {
+ background: #333;
+}
details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary::before,
nav.main .separator {
border: 1px solid #000;
}
+
a {
- color: #000;
+ color: #3873AD;
}
-body.source .example-wrap pre.rust a {
- background: #eee;
+a.srclink,
+a#toggle-all-docs,
+#source-sidebar a,
+pre.rust a,
+.sidebar a,
+.in-band a {
+ color: #000;
}
-
-.docblock:not(.item-decl) a:not(.srclink):not(.test-arrow),
-.docblock-short a:not(.srclink):not(.test-arrow), .item-info a,
-#help a {
- color: #3873AD;
+.search-results a {
+ color: initial;
}
-
a.test-arrow {
color: #f5f5f5;
}
+body.source .example-wrap pre.rust a {
+ background: #eee;
+}
details.rustdoc-toggle > summary.hideme > span,
details.rustdoc-toggle > summary::before,
}
});
+ onEachLazy(document.querySelectorAll(".rustdoc-toggle > summary:not(.hideme)"), function(el) {
+ el.addEventListener("click", function(e) {
+ if (e.target.tagName != "SUMMARY") {
+ e.preventDefault();
+ }
+ });
+ });
+
onEachLazy(document.getElementsByClassName("notable-traits"), function(e) {
e.onclick = function() {
this.getElementsByClassName('notable-traits-tooltiptext')[0]
></script> {#- -#}
<script src="{{static_root_path | safe}}storage{{page.resource_suffix}}.js"></script> {#- -#}
<script src="{{page.root_path | safe}}crates{{page.resource_suffix}}.js"></script> {#- -#}
+ <script defer src="{{static_root_path | safe}}main{{page.resource_suffix}}.js"></script> {#- -#}
+ {%- for script in page.static_extra_scripts -%}
+ <script defer src="{{static_root_path | safe}}{{script}}.js"></script> {#- -#}
+ {% endfor %}
+ {%- if layout.scrape_examples_extension -%}
+ <script defer src="{{page.root_path | safe}}scrape-examples{{page.resource_suffix}}.js"></script> {#- -#}
+ {%- endif -%}
+ {%- for script in page.extra_scripts -%}
+ <script defer src="{{page.root_path | safe}}{{script}}.js"></script> {#- -#}
+ {% endfor %}
<noscript> {#- -#}
<link rel="stylesheet" {# -#}
href="{{static_root_path | safe}}noscript{{page.resource_suffix}}.css"> {#- -#}
data-search-index-js="{{page.root_path | safe}}search-index{{page.resource_suffix}}.js" {# -#}
data-search-js="{{static_root_path | safe}}search{{page.resource_suffix}}.js"> {#- -#}
</div>
- <script src="{{static_root_path | safe}}main{{page.resource_suffix}}.js"></script> {#- -#}
- {%- for script in page.static_extra_scripts -%}
- <script src="{{static_root_path | safe}}{{script}}.js"></script> {#- -#}
- {% endfor %}
- {%- if layout.scrape_examples_extension -%}
- <script src="{{page.root_path | safe}}scrape-examples{{page.resource_suffix}}.js"></script> {#- -#}
- {%- endif -%}
- {%- for script in page.extra_scripts -%}
- <script src="{{page.root_path | safe}}{{script}}.js"></script> {#- -#}
- {% endfor %}
</body> {#- -#}
</html> {#- -#}
use std::cmp;
+use rustc_span::symbol::kw;
+
use crate::clean::{self, DocFragment, DocFragmentKind, Item};
use crate::core::DocContext;
use crate::fold::{self, DocFolder};
};
for fragment in docs {
- if fragment.doc.as_str().lines().count() == 0 {
+ if fragment.doc == kw::Empty {
continue;
}
fn create_doc_fragment(s: &str) -> Vec<DocFragment> {
vec![DocFragment {
- line: 0,
span: DUMMY_SP,
parent_module: None,
doc: Symbol::intern(s),
--- /dev/null
+// revisions: all strong basic none missing
+// assembly-output: emit-asm
+// ignore-macos slightly different policy on stack protection of arrays
+// ignore-windows stack check code uses different function names
+// ignore-nvptx64 stack protector is not supported
+// [all] compile-flags: -Z stack-protector=all
+// [strong] compile-flags: -Z stack-protector=strong
+// [basic] compile-flags: -Z stack-protector=basic
+// [none] compile-flags: -Z stack-protector=none
+// compile-flags: -C opt-level=2 -Z merge-functions=disabled
+
+#![crate_type = "lib"]
+
+#![allow(incomplete_features)]
+
+#![feature(unsized_locals, unsized_fn_params)]
+
+
+// CHECK-LABEL: emptyfn:
+#[no_mangle]
+pub fn emptyfn() {
+ // all: __stack_chk_fail
+ // strong-NOT: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: array_char
+#[no_mangle]
+pub fn array_char(f: fn(*const char)) {
+ let a = ['c'; 1];
+ let b = ['d'; 3];
+ let c = ['e'; 15];
+
+ f(&a as *const _);
+ f(&b as *const _);
+ f(&c as *const _);
+
+ // Any type of local array variable leads to stack protection with the
+ // "strong" heuristic. The 'basic' heuristic only adds stack protection to
+ // functions with local array variables of a byte-sized type, however. Since
+ // 'char' is 4 bytes in Rust, this function is not protected by the 'basic'
+ // heuristic
+ //
+ // (This test *also* takes the address of the local stack variables. We
+ // cannot know that this isn't what triggers the `strong` heuristic.
+ // However, the test strategy of passing the address of a stack array to an
+ // external function is sufficient to trigger the `basic` heuristic (see
+ // test `array_u8_large()`). Since the `basic` heuristic only checks for the
+ // presence of stack-local array variables, we can be confident that this
+ // test also captures this part of the `strong` heuristic specification.)
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: array_u8_1
+#[no_mangle]
+pub fn array_u8_1(f: fn(*const u8)) {
+ let a = [0u8; 1];
+ f(&a as *const _);
+
+ // The 'strong' heuristic adds stack protection to functions with local
+ // array variables regardless of their size.
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: array_u8_small:
+#[no_mangle]
+pub fn array_u8_small(f: fn(*const u8)) {
+ let a = [0u8; 2];
+ let b = [0u8; 8];
+ f(&a as *const _);
+ f(&b as *const _);
+
+ // Small arrays do not lead to stack protection by the 'basic' heuristic.
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: array_u8_large:
+#[no_mangle]
+pub fn array_u8_large(f: fn(*const u8)) {
+ let a = [0u8; 9];
+ f(&a as *const _);
+
+ // Since `a` is a byte array with size greater than 8, the basic heuristic
+ // will also protect this function.
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+#[derive(Copy, Clone)]
+pub struct ByteSizedNewtype(u8);
+
+// CHECK-LABEL: array_bytesizednewtype_9:
+#[no_mangle]
+pub fn array_bytesizednewtype_9(f: fn(*const ByteSizedNewtype)) {
+ let a = [ByteSizedNewtype(0); 9];
+ f(&a as *const _);
+
+ // Since `a` is a byte array in the LLVM output, the basic heuristic will
+ // also protect this function.
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: local_var_addr_used_indirectly
+#[no_mangle]
+pub fn local_var_addr_used_indirectly(f: fn(bool)) {
+ let a = 5;
+ let a_addr = &a as *const _ as usize;
+ f(a_addr & 0x10 == 0);
+
+ // This function takes the address of a local variable taken. Although this
+ // address is never used as a way to refer to stack memory, the `strong`
+ // heuristic adds stack smash protection. This is also the case in C++:
+ // ```
+ // cat << EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk
+ // #include <cstdint>
+ // void f(void (*g)(bool)) {
+ // int32_t x;
+ // g((reinterpret_cast<uintptr_t>(&x) & 0x10U) == 0);
+ // }
+ // EOF
+ // ```
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+
+// CHECK-LABEL: local_string_addr_taken
+#[no_mangle]
+pub fn local_string_addr_taken(f: fn(&String)) {
+ let x = String::new();
+ f(&x);
+
+ // Taking the address of the local variable `x` leads to stack smash
+ // protection with the `strong` heuristic, but not with the `basic`
+ // heuristic. It does not matter that the reference is not mut.
+ //
+ // An interesting note is that a similar function in C++ *would* be
+ // protected by the `basic` heuristic, because `std::string` has a char
+ // array internally as a small object optimization:
+ // ```
+ // cat <<EOF | clang++ -O2 -fstack-protector -S -x c++ - -o - | grep stack_chk
+ // #include <string>
+ // void f(void (*g)(const std::string&)) {
+ // std::string x;
+ // g(x);
+ // }
+ // EOF
+ // ```
+ //
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+pub trait SelfByRef {
+ fn f(&self) -> i32;
+}
+
+impl SelfByRef for i32 {
+ fn f(&self) -> i32 {
+ return self + 1;
+ }
+}
+
+// CHECK-LABEL: local_var_addr_taken_used_locally_only
+#[no_mangle]
+pub fn local_var_addr_taken_used_locally_only(factory: fn() -> i32, sink: fn(i32)) {
+ let x = factory();
+ let g = x.f();
+ sink(g);
+
+ // Even though the local variable conceptually has its address taken, as
+ // it's passed by reference to the trait function, the use of the reference
+ // is easily inlined. There is therefore no stack smash protection even with
+ // the `strong` heuristic.
+
+ // all: __stack_chk_fail
+ // strong-NOT: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+pub struct Gigastruct {
+ does: u64,
+ not: u64,
+ have: u64,
+ array: u64,
+ members: u64
+}
+
+// CHECK-LABEL: local_large_var_moved
+#[no_mangle]
+pub fn local_large_var_moved(f: fn(Gigastruct)) {
+ let x = Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 };
+ f(x);
+
+ // Even though the local variable conceptually doesn't have its address
+ // taken, it's so large that the "move" is implemented with a reference to a
+ // stack-local variable in the ABI. Consequently, this function *is*
+ // protected by the `strong` heuristic. This is also the case for
+ // rvalue-references in C++, regardless of struct size:
+ // ```
+ // cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk
+ // #include <cstdint>
+ // #include <utility>
+ // void f(void (*g)(uint64_t&&)) {
+ // uint64_t x;
+ // g(std::move(x));
+ // }
+ // EOF
+ // ```
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: local_large_var_cloned
+#[no_mangle]
+pub fn local_large_var_cloned(f: fn(Gigastruct)) {
+ f(Gigastruct { does: 0, not: 1, have: 2, array: 3, members: 4 });
+
+ // A new instance of `Gigastruct` is passed to `f()`, without any apparent
+ // connection to this stack frame. Still, since instances of `Gigastruct`
+ // are sufficiently large, it is allocated in the caller stack frame and
+ // passed as a pointer. As such, this function is *also* protected by the
+ // `strong` heuristic, just like `local_large_var_moved`. This is also the
+ // case for pass-by-value of sufficiently large structs in C++:
+ // ```
+ // cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk
+ // #include <cstdint>
+ // #include <utility>
+ // struct Gigastruct { uint64_t a, b, c, d, e; };
+ // void f(void (*g)(Gigastruct)) {
+ // g(Gigastruct{});
+ // }
+ // EOF
+ // ```
+
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+
+extern "C" {
+ // A call to an external `alloca` function is *not* recognized as an
+ // `alloca(3)` operation. This function is a compiler built-in, as the
+ // man page explains. Clang translates it to an LLVM `alloca`
+ // instruction with a count argument, which is also what the LLVM stack
+ // protector heuristics looks for. The man page for `alloca(3)` details
+ // a way to avoid using the compiler built-in: pass a -std=c11
+ // argument, *and* don't include <alloca.h>. Though this leads to an
+ // external alloca() function being called, it doesn't lead to stack
+ // protection being included. It even fails with a linker error
+ // "undefined reference to `alloca'". Example:
+ // ```
+ // cat<<EOF | clang -fstack-protector-strong -x c -std=c11 - -o /dev/null
+ // #include <stdlib.h>
+ // void * alloca(size_t);
+ // void f(void (*g)(void*)) {
+ // void * p = alloca(10);
+ // g(p);
+ // }
+ // int main() { return 0; }
+ // EOF
+ // ```
+ // The following tests demonstrate that calls to an external `alloca`
+ // function in Rust also doesn't trigger stack protection.
+
+ fn alloca(size: usize) -> *mut ();
+}
+
+// CHECK-LABEL: alloca_small_compile_time_constant_arg
+#[no_mangle]
+pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) {
+ f(unsafe { alloca(8) });
+
+ // all: __stack_chk_fail
+ // strong-NOT: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: alloca_large_compile_time_constant_arg
+#[no_mangle]
+pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
+ f(unsafe { alloca(9) });
+
+ // all: __stack_chk_fail
+ // strong-NOT: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+
+// CHECK-LABEL: alloca_dynamic_arg
+#[no_mangle]
+pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
+ f(unsafe { alloca(n) });
+
+ // all: __stack_chk_fail
+ // strong-NOT: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// The question then is: in what ways can Rust code generate array-`alloca`
+// LLVM instructions? This appears to only be generated by
+// rustc_codegen_ssa::traits::Builder::array_alloca() through
+// rustc_codegen_ssa::mir::operand::OperandValue::store_unsized(). FWICT
+// this is support for the "unsized locals" unstable feature:
+// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
+
+
+// CHECK-LABEL: unsized_fn_param
+#[no_mangle]
+pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
+ let n = if l { 1 } else { 2 };
+ f(*Box::<[u8]>::from(&s[0..n])); // slice-copy with Box::from
+
+ // Even though slices are conceptually passed by-value both into this
+ // function and into `f()`, this is implemented with pass-by-reference
+ // using a suitably constructed fat-pointer (as if the functions
+ // accepted &[u8]). This function therefore doesn't need dynamic array
+ // alloca, and is therefore not protected by the `strong` or `basic`
+ // heuristics.
+
+
+ // all: __stack_chk_fail
+ // strong-NOT: __stack_chk_fail
+ // basic-NOT: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
+
+// CHECK-LABEL: unsized_local
+#[no_mangle]
+pub fn unsized_local(s: &[u8], l: bool, f: fn(&mut [u8])) {
+ let n = if l { 1 } else { 2 };
+ let mut a: [u8] = *Box::<[u8]>::from(&s[0..n]); // slice-copy with Box::from
+ f(&mut a);
+
+ // This function allocates a slice as a local variable in its stack
+ // frame. Since the size is not a compile-time constant, an array
+ // alloca is required, and the function is protected by both the
+ // `strong` and `basic` heuristic.
+
+ // all: __stack_chk_fail
+ // strong: __stack_chk_fail
+ // basic: __stack_chk_fail
+ // none-NOT: __stack_chk_fail
+ // missing-NOT: __stack_chk_fail
+}
--- /dev/null
+// Test that stack smash protection code is emitted for all tier1 and tier2
+// targets, with the exception of nvptx64-nvidia-cuda
+//
+// revisions: r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 r23
+// revisions: r24 r25 r26 r27 r28 r29 r30 r31 r32 r33 r34 r35 r36 r37 r38 r39 r40 r41 r42 r43 r44
+// revisions: r45 r46 r47 r48 r49 r50 r51 r52 r53 r54 r55 r56 r57 r58 r59 r60 r61 r62 r63 r64 r65
+// revisions: r66 r67 r68 r69 r70 r71 r72 r73 r74 r75 r76 r77 r78 r79 r80 r81 r82 r83 r84
+// assembly-output: emit-asm
+// [r1] compile-flags: --target aarch64-unknown-linux-gnu
+// [r1] needs-llvm-components: aarch64
+// [r2] compile-flags: --target i686-pc-windows-gnu
+// [r2] needs-llvm-components: x86
+// [r3] compile-flags: --target i686-pc-windows-msvc
+// [r3] needs-llvm-components: x86
+// [r4] compile-flags: --target i686-unknown-linux-gnu
+// [r4] needs-llvm-components: x86
+// [r5] compile-flags: --target x86_64-apple-darwin
+// [r5] needs-llvm-components: x86
+// [r6] compile-flags: --target x86_64-pc-windows-gnu
+// [r6] needs-llvm-components: x86
+// [r7] compile-flags: --target x86_64-pc-windows-msvc
+// [r7] needs-llvm-components: x86
+// [r8] compile-flags: --target x86_64-unknown-linux-gnu
+// [r8] needs-llvm-components: x86
+// [r9] compile-flags: --target aarch64-apple-darwin
+// [r9] needs-llvm-components: aarch64
+// [r10] compile-flags: --target aarch64-apple-ios
+// [r10] needs-llvm-components: aarch64
+// [r11] compile-flags: --target aarch64-fuchsia
+// [r11] needs-llvm-components: aarch64
+// [r12] compile-flags: --target aarch64-linux-android
+// [r12] needs-llvm-components: aarch64
+// [r13] compile-flags: --target aarch64-pc-windows-msvc
+// [r13] needs-llvm-components: aarch64
+// [r14] compile-flags: --target aarch64-unknown-linux-musl
+// [r14] needs-llvm-components: aarch64
+// [r15] compile-flags: --target aarch64-unknown-none
+// [r15] needs-llvm-components: aarch64
+// [r16] compile-flags: --target aarch64-unknown-none-softfloat
+// [r16] needs-llvm-components: aarch64
+// [r17] compile-flags: --target arm-linux-androideabi
+// [r17] needs-llvm-components: arm
+// [r18] compile-flags: --target arm-unknown-linux-gnueabi
+// [r18] needs-llvm-components: arm
+// [r19] compile-flags: --target arm-unknown-linux-gnueabihf
+// [r19] needs-llvm-components: arm
+// [r20] compile-flags: --target arm-unknown-linux-musleabi
+// [r20] needs-llvm-components: arm
+// [r21] compile-flags: --target arm-unknown-linux-musleabihf
+// [r21] needs-llvm-components: arm
+// [r22] compile-flags: --target armebv7r-none-eabi
+// [r22] needs-llvm-components: arm
+// [r23] compile-flags: --target armebv7r-none-eabihf
+// [r23] needs-llvm-components: arm
+// [r24] compile-flags: --target armv5te-unknown-linux-gnueabi
+// [r24] needs-llvm-components: arm
+// [r25] compile-flags: --target armv5te-unknown-linux-musleabi
+// [r25] needs-llvm-components: arm
+// [r26] compile-flags: --target armv7-linux-androideabi
+// [r26] needs-llvm-components: arm
+// [r27] compile-flags: --target armv7a-none-eabi
+// [r27] needs-llvm-components: arm
+// [r28] compile-flags: --target armv7r-none-eabi
+// [r28] needs-llvm-components: arm
+// [r29] compile-flags: --target armv7r-none-eabihf
+// [r29] needs-llvm-components: arm
+// [r30] compile-flags: --target armv7-unknown-linux-gnueabi
+// [r30] needs-llvm-components: arm
+// [r31] compile-flags: --target armv7-unknown-linux-gnueabihf
+// [r31] needs-llvm-components: arm
+// [r32] compile-flags: --target armv7-unknown-linux-musleabi
+// [r32] needs-llvm-components: arm
+// [r33] compile-flags: --target armv7-unknown-linux-musleabihf
+// [r33] needs-llvm-components: arm
+// [r34] compile-flags: --target asmjs-unknown-emscripten
+// [r34] needs-llvm-components: webassembly
+// [r35] compile-flags: --target i586-pc-windows-msvc
+// [r35] needs-llvm-components: x86
+// [r36] compile-flags: --target i586-unknown-linux-gnu
+// [r36] needs-llvm-components: x86
+// [r37] compile-flags: --target i586-unknown-linux-musl
+// [r37] needs-llvm-components: x86
+// [r38] compile-flags: --target i686-linux-android
+// [r38] needs-llvm-components: x86
+// [r39] compile-flags: --target i686-unknown-freebsd
+// [r39] needs-llvm-components: x86
+// [r40] compile-flags: --target i686-unknown-linux-musl
+// [r40] needs-llvm-components: x86
+// [r41] compile-flags: --target mips-unknown-linux-gnu
+// [r41] needs-llvm-components: mips
+// [r42] compile-flags: --target mips-unknown-linux-musl
+// [r42] needs-llvm-components: mips
+// [r43] compile-flags: --target mips64-unknown-linux-gnuabi64
+// [r43] needs-llvm-components: mips
+// [r44] compile-flags: --target mips64-unknown-linux-muslabi64
+// [r44] needs-llvm-components: mips
+// [r45] compile-flags: --target mips64el-unknown-linux-gnuabi64
+// [r45] needs-llvm-components: mips
+// [r46] compile-flags: --target mips64el-unknown-linux-muslabi64
+// [r46] needs-llvm-components: mips
+// [r47] compile-flags: --target mipsel-unknown-linux-gnu
+// [r47] needs-llvm-components: mips
+// [r48] compile-flags: --target mipsel-unknown-linux-musl
+// [r48] needs-llvm-components: mips
+// [r49] compile-flags: --target nvptx64-nvidia-cuda
+// [r49] needs-llvm-components: nvptx
+// [r50] compile-flags: --target powerpc-unknown-linux-gnu
+// [r50] needs-llvm-components: powerpc
+// [r51] compile-flags: --target powerpc64-unknown-linux-gnu
+// [r51] needs-llvm-components: powerpc
+// [r52] compile-flags: --target powerpc64le-unknown-linux-gnu
+// [r52] needs-llvm-components: powerpc
+// [r53] compile-flags: --target riscv32i-unknown-none-elf
+// [r53] needs-llvm-components: riscv
+// [r54] compile-flags: --target riscv32imac-unknown-none-elf
+// [r54] needs-llvm-components: riscv
+// [r55] compile-flags:--target riscv32imc-unknown-none-elf
+// [r55] needs-llvm-components: riscv
+// [r56] compile-flags:--target riscv64gc-unknown-linux-gnu
+// [r56] needs-llvm-components: riscv
+// [r57] compile-flags:--target riscv64gc-unknown-none-elf
+// [r57] needs-llvm-components: riscv
+// [r58] compile-flags:--target riscv64imac-unknown-none-elf
+// [r58] needs-llvm-components: riscv
+// [r59] compile-flags:--target s390x-unknown-linux-gnu
+// [r59] needs-llvm-components: systemz
+// [r60] compile-flags:--target sparc64-unknown-linux-gnu
+// [r60] needs-llvm-components: sparc
+// [r61] compile-flags:--target sparcv9-sun-solaris
+// [r61] needs-llvm-components: sparc
+// [r62] compile-flags:--target thumbv6m-none-eabi
+// [r62] needs-llvm-components: arm
+// [r63] compile-flags:--target thumbv7em-none-eabi
+// [r63] needs-llvm-components: arm
+// [r64] compile-flags:--target thumbv7em-none-eabihf
+// [r64] needs-llvm-components: arm
+// [r65] compile-flags:--target thumbv7m-none-eabi
+// [r65] needs-llvm-components: arm
+// [r66] compile-flags:--target thumbv7neon-linux-androideabi
+// [r66] needs-llvm-components: arm
+// [r67] compile-flags:--target thumbv7neon-unknown-linux-gnueabihf
+// [r67] needs-llvm-components: arm
+// [r68] compile-flags:--target thumbv8m.base-none-eabi
+// [r68] needs-llvm-components: arm
+// [r69] compile-flags:--target thumbv8m.main-none-eabi
+// [r69] needs-llvm-components: arm
+// [r70] compile-flags:--target thumbv8m.main-none-eabihf
+// [r70] needs-llvm-components: arm
+// [r71] compile-flags:--target wasm32-unknown-emscripten
+// [r71] needs-llvm-components: webassembly
+// [r72] compile-flags:--target wasm32-unknown-unknown
+// [r72] needs-llvm-components: webassembly
+// [r73] compile-flags:--target wasm32-wasi
+// [r73] needs-llvm-components: webassembly
+// [r74] compile-flags:--target x86_64-apple-ios
+// [r74] needs-llvm-components: x86
+// [r75] compile-flags:--target x86_64-fortanix-unknown-sgx
+// [r75] needs-llvm-components: x86
+// [r75] min-llvm-version: 11.0.0
+// [r76] compile-flags:--target x86_64-fuchsia
+// [r76] needs-llvm-components: x86
+// [r77] compile-flags:--target x86_64-linux-android
+// [r77] needs-llvm-components: x86
+// [r78] compile-flags:--target x86_64-sun-solaris
+// [r78] needs-llvm-components: x86
+// [r79] compile-flags:--target x86_64-unknown-freebsd
+// [r79] needs-llvm-components: x86
+// [r80] compile-flags:--target x86_64-unknown-illumos
+// [r80] needs-llvm-components: x86
+// [r81] compile-flags:--target x86_64-unknown-linux-gnux32
+// [r81] needs-llvm-components: x86
+// [r82] compile-flags:--target x86_64-unknown-linux-musl
+// [r82] needs-llvm-components: x86
+// [r83] compile-flags:--target x86_64-unknown-netbsd
+// [r83] needs-llvm-components: x86
+// [r84] compile-flags: --target x86_64-unknown-redox
+// [r84] needs-llvm-components: x86
+// compile-flags: -Z stack-protector=all
+// compile-flags: -C opt-level=2
+
+#![crate_type = "lib"]
+
+#![feature(no_core, lang_items)]
+#![crate_type = "lib"]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+
+#[no_mangle]
+pub fn foo() {
+ // CHECK: foo{{:|()}}
+
+ // MSVC does the stack checking within a stack-check function:
+ // r3: calll @__security_check_cookie
+ // r7: callq __security_check_cookie
+ // r13: bl __security_check_cookie
+ // r35: calll @__security_check_cookie
+
+ // cuda doesn't support stack-smash protection
+ // r49-NOT: __security_check_cookie
+ // r49-NOT: __stack_chk_fail
+
+ // Other targets do stack checking within the function, and call a failure function on error
+ // r1: __stack_chk_fail
+ // r2: __stack_chk_fail
+ // r4: __stack_chk_fail
+ // r5: __stack_chk_fail
+ // r6: __stack_chk_fail
+ // r8: __stack_chk_fail
+ // r9: __stack_chk_fail
+ // r10: __stack_chk_fail
+ // r11: __stack_chk_fail
+ // r12: __stack_chk_fail
+ // r14: __stack_chk_fail
+ // r15: __stack_chk_fail
+ // r16: __stack_chk_fail
+ // r17: __stack_chk_fail
+ // r18: __stack_chk_fail
+ // r19: __stack_chk_fail
+ // r20: __stack_chk_fail
+ // r21: __stack_chk_fail
+ // r22: __stack_chk_fail
+ // r23: __stack_chk_fail
+ // r24: __stack_chk_fail
+ // r25: __stack_chk_fail
+ // r26: __stack_chk_fail
+ // r27: __stack_chk_fail
+ // r28: __stack_chk_fail
+ // r29: __stack_chk_fail
+ // r30: __stack_chk_fail
+ // r31: __stack_chk_fail
+ // r32: __stack_chk_fail
+ // r33: __stack_chk_fail
+ // r34: __stack_chk_fail
+ // r36: __stack_chk_fail
+ // r37: __stack_chk_fail
+ // r38: __stack_chk_fail
+ // r39: __stack_chk_fail
+ // r40: __stack_chk_fail
+ // r41: __stack_chk_fail
+ // r42: __stack_chk_fail
+ // r43: __stack_chk_fail
+ // r44: __stack_chk_fail
+ // r45: __stack_chk_fail
+ // r46: __stack_chk_fail
+ // r47: __stack_chk_fail
+ // r48: __stack_chk_fail
+ // r50: __stack_chk_fail
+ // r51: __stack_chk_fail
+ // r52: __stack_chk_fail
+ // r53: __stack_chk_fail
+ // r54: __stack_chk_fail
+ // r55: __stack_chk_fail
+ // r56: __stack_chk_fail
+ // r57: __stack_chk_fail
+ // r58: __stack_chk_fail
+ // r59: __stack_chk_fail
+ // r60: __stack_chk_fail
+ // r61: __stack_chk_fail
+ // r62: __stack_chk_fail
+ // r63: __stack_chk_fail
+ // r64: __stack_chk_fail
+ // r65: __stack_chk_fail
+ // r66: __stack_chk_fail
+ // r67: __stack_chk_fail
+ // r68: __stack_chk_fail
+ // r69: __stack_chk_fail
+ // r70: __stack_chk_fail
+ // r71: __stack_chk_fail
+ // r72: __stack_chk_fail
+ // r73: __stack_chk_fail
+ // r74: __stack_chk_fail
+ // r75: __stack_chk_fail
+ // r76: __stack_chk_fail
+ // r77: __stack_chk_fail
+ // r78: __stack_chk_fail
+ // r79: __stack_chk_fail
+ // r80: __stack_chk_fail
+ // r81: __stack_chk_fail
+ // r82: __stack_chk_fail
+ // r83: __stack_chk_fail
+ // r84: __stack_chk_fail
+}
--- /dev/null
+// revisions: all strong basic none
+// ignore-nvptx64 stack protector not supported
+// [all] compile-flags: -Z stack-protector=all
+// [strong] compile-flags: -Z stack-protector=strong
+// [basic] compile-flags: -Z stack-protector=basic
+
+#![crate_type = "lib"]
+
+#[no_mangle]
+pub fn foo() {
+ // CHECK: @foo() unnamed_addr #0
+
+ // all-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
+ // all-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+ // all: attributes #0 = { {{.*}} sspreq {{.*}} }
+ // all-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
+ // all-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+
+ // strong-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
+ // strong-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+ // strong: attributes #0 = { {{.*}} sspstrong {{.*}} }
+ // strong-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
+ // strong-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+
+ // basic-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
+ // basic-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
+ // basic: attributes #0 = { {{.*}} ssp {{.*}} }
+ // basic-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
+ // basic-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
+
+ // none-NOT: attributes #0 = { {{.*}} sspreq {{.*}} }
+ // none-NOT: attributes #0 = { {{.*}} sspstrong {{.*}} }
+ // none-NOT: attributes #0 = { {{.*}} ssp {{.*}} }
+}
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
#[rustc_clean(cfg="cfail3")]
-#[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
+#[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")]
#[rustc_clean(cfg="cfail6")]
pub fn add_loop_label_to_break() {
let mut _x = 0;
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(except="hir_owner", cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
-#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail5")]
+#[rustc_clean(except="hir_owner", cfg="cfail5")]
#[rustc_clean(cfg="cfail6")]
pub trait TraitVisibility { }
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(except="hir_owner", cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
-#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail5")]
+#[rustc_clean(except="hir_owner", cfg="cfail5")]
#[rustc_clean(cfg="cfail6")]
unsafe trait TraitUnsafety { }
#[cfg(not(any(cfail1,cfail4)))]
#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
-#[rustc_clean(except="hir_owner,associated_item_def_ids,predicates_of", cfg="cfail5")]
+#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail5")]
#[rustc_clean(cfg="cfail6")]
pub trait TraitAddMethod {
fn method();
// no-prefer-dynamic
-//[cfail1] compile-flags: -lbar -lfoo --crate-type lib
-//[cfail2] compile-flags: -lfoo -lbar --crate-type lib
+//[cfail1] compile-flags: -lbar -lfoo --crate-type lib -Zassert-incr-state=not-loaded
+//[cfail2] compile-flags: -lfoo -lbar --crate-type lib -Zassert-incr-state=not-loaded
// revisions:rpass1 cfail2
// compile-flags: -Z query-dep-graph
+// [cfail2] compile-flags: -Z query-dep-graph -Z assert-incr-state=loaded
#![feature(rustc_attrs)]
let mut _2: std::ops::Range<i32>; // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
let mut _3: std::ops::Range<i32>; // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
let mut _5: (); // in scope 0 at $DIR/remove_storage_markers.rs:6:1: 11:2
- let _7: (); // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
- let mut _8: std::option::Option<i32>; // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ let _6: (); // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ let mut _7: std::option::Option<i32>; // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ let mut _8: &mut std::ops::Range<i32>; // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
let mut _9: &mut std::ops::Range<i32>; // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
- let mut _10: &mut std::ops::Range<i32>; // in scope 0 at $DIR/remove_storage_markers.rs:8:14: 8:19
- let mut _11: isize; // in scope 0 at $DIR/remove_storage_markers.rs:8:9: 8:10
- let mut _13: i32; // in scope 0 at $DIR/remove_storage_markers.rs:8:9: 8:10
- let mut _14: !; // in scope 0 at $DIR/remove_storage_markers.rs:8:5: 10:6
- let _16: (); // in scope 0 at $DIR/remove_storage_markers.rs:8:20: 10:6
- let mut _17: i32; // in scope 0 at $DIR/remove_storage_markers.rs:9:16: 9:17
+ let mut _10: isize; // in scope 0 at $DIR/remove_storage_markers.rs:8:5: 10:6
+ let mut _11: !; // in scope 0 at $DIR/remove_storage_markers.rs:8:5: 10:6
+ let mut _13: i32; // in scope 0 at $DIR/remove_storage_markers.rs:9:16: 9:17
scope 1 {
debug sum => _1; // in scope 1 at $DIR/remove_storage_markers.rs:7:9: 7:16
let mut _4: std::ops::Range<i32>; // in scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19
scope 2 {
debug iter => _4; // in scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
- let mut _6: i32; // in scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ let _12: i32; // in scope 2 at $DIR/remove_storage_markers.rs:8:9: 8:10
scope 3 {
- debug __next => _6; // in scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
- let _12: i32; // in scope 3 at $DIR/remove_storage_markers.rs:8:9: 8:10
- let _15: i32; // in scope 3 at $DIR/remove_storage_markers.rs:8:9: 8:10
- scope 4 {
- debug val => _12; // in scope 4 at $DIR/remove_storage_markers.rs:8:9: 8:10
- }
- scope 5 {
- debug i => _15; // in scope 5 at $DIR/remove_storage_markers.rs:8:9: 8:10
- }
- scope 7 (inlined iter::range::<impl Iterator for std::ops::Range<i32>>::next) { // at $DIR/remove_storage_markers.rs:8:14: 8:19
- debug self => _9; // in scope 7 at $DIR/remove_storage_markers.rs:8:14: 8:19
- let mut _18: &mut std::ops::Range<i32>; // in scope 7 at $DIR/remove_storage_markers.rs:8:14: 8:19
- }
+ debug i => _12; // in scope 3 at $DIR/remove_storage_markers.rs:8:9: 8:10
+ }
+ scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<i32>>::next) { // at $DIR/remove_storage_markers.rs:8:14: 8:19
+ debug self => _8; // in scope 5 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ let mut _14: &mut std::ops::Range<i32>; // in scope 5 at $DIR/remove_storage_markers.rs:8:14: 8:19
}
}
- scope 6 (inlined <std::ops::Range<i32> as IntoIterator>::into_iter) { // at $DIR/remove_storage_markers.rs:8:14: 8:19
- debug self => _3; // in scope 6 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ scope 4 (inlined <std::ops::Range<i32> as IntoIterator>::into_iter) { // at $DIR/remove_storage_markers.rs:8:14: 8:19
+ debug self => _3; // in scope 4 at $DIR/remove_storage_markers.rs:8:14: 8:19
}
}
- StorageLive(_3); // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19
(_3.0: i32) = const 0_i32; // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19
(_3.1: i32) = const 10_i32; // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19
- _2 = move _3; // scope 6 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ _2 = move _3; // scope 4 at $DIR/remove_storage_markers.rs:8:14: 8:19
- StorageDead(_3); // scope 1 at $DIR/remove_storage_markers.rs:8:18: 8:19
- StorageLive(_4); // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19
_4 = move _2; // scope 1 at $DIR/remove_storage_markers.rs:8:14: 8:19
bb1: {
- StorageLive(_6); // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
-- StorageLive(_7); // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
-- StorageLive(_8); // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
-- StorageLive(_9); // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
-- StorageLive(_10); // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
- _10 = &mut _4; // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
- _9 = &mut (*_10); // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
-- StorageLive(_18); // scope 7 at $DIR/remove_storage_markers.rs:8:14: 8:19
- _18 = &mut (*_9); // scope 7 at $DIR/remove_storage_markers.rs:8:14: 8:19
- _8 = <std::ops::Range<i32> as iter::range::RangeIteratorImpl>::spec_next(move _18) -> bb4; // scope 7 at $DIR/remove_storage_markers.rs:8:14: 8:19
+- StorageLive(_7); // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
+- StorageLive(_8); // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
+- StorageLive(_9); // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ _9 = &mut _4; // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ _8 = &mut (*_9); // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
+- StorageLive(_14); // scope 5 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ _14 = &mut (*_8); // scope 5 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ _7 = <std::ops::Range<i32> as iter::range::RangeIteratorImpl>::spec_next(move _14) -> bb4; // scope 5 at $DIR/remove_storage_markers.rs:8:14: 8:19
// mir::Constant
// + span: $DIR/remove_storage_markers.rs:8:14: 8:19
// + literal: Const { ty: for<'r> fn(&'r mut std::ops::Range<i32>) -> std::option::Option<<std::ops::Range<i32> as std::iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<i32> as std::iter::range::RangeIteratorImpl>::spec_next}, val: Value(Scalar(<ZST>)) }
}
bb2: {
- _0 = const (); // scope 3 at $DIR/remove_storage_markers.rs:8:5: 10:6
-- StorageDead(_10); // scope 3 at $DIR/remove_storage_markers.rs:8:18: 8:19
-- StorageDead(_8); // scope 3 at $DIR/remove_storage_markers.rs:8:18: 8:19
-- StorageDead(_7); // scope 3 at $DIR/remove_storage_markers.rs:8:18: 8:19
+- StorageLive(_12); // scope 2 at $DIR/remove_storage_markers.rs:8:9: 8:10
+ _12 = ((_7 as Some).0: i32); // scope 2 at $DIR/remove_storage_markers.rs:8:9: 8:10
+- StorageLive(_13); // scope 3 at $DIR/remove_storage_markers.rs:9:16: 9:17
+ _13 = _12; // scope 3 at $DIR/remove_storage_markers.rs:9:16: 9:17
+ _1 = Add(_1, move _13); // scope 3 at $DIR/remove_storage_markers.rs:9:9: 9:17
+- StorageDead(_13); // scope 3 at $DIR/remove_storage_markers.rs:9:16: 9:17
+ _6 = const (); // scope 3 at $DIR/remove_storage_markers.rs:8:20: 10:6
+- StorageDead(_12); // scope 2 at $DIR/remove_storage_markers.rs:10:5: 10:6
+- StorageDead(_9); // scope 2 at $DIR/remove_storage_markers.rs:10:5: 10:6
+- StorageDead(_7); // scope 2 at $DIR/remove_storage_markers.rs:10:5: 10:6
- StorageDead(_6); // scope 2 at $DIR/remove_storage_markers.rs:10:5: 10:6
-- StorageDead(_4); // scope 1 at $DIR/remove_storage_markers.rs:10:5: 10:6
-- StorageDead(_2); // scope 1 at $DIR/remove_storage_markers.rs:10:5: 10:6
-- StorageDead(_1); // scope 0 at $DIR/remove_storage_markers.rs:11:1: 11:2
- return; // scope 0 at $DIR/remove_storage_markers.rs:11:2: 11:2
+ _5 = const (); // scope 2 at $DIR/remove_storage_markers.rs:8:5: 10:6
+ goto -> bb1; // scope 2 at $DIR/remove_storage_markers.rs:8:5: 10:6
}
bb3: {
-- StorageLive(_12); // scope 3 at $DIR/remove_storage_markers.rs:8:9: 8:10
- _12 = ((_8 as Some).0: i32); // scope 3 at $DIR/remove_storage_markers.rs:8:9: 8:10
-- StorageLive(_13); // scope 4 at $DIR/remove_storage_markers.rs:8:9: 8:10
- _13 = _12; // scope 4 at $DIR/remove_storage_markers.rs:8:9: 8:10
- _6 = move _13; // scope 4 at $DIR/remove_storage_markers.rs:8:9: 8:10
- _7 = const (); // scope 4 at $DIR/remove_storage_markers.rs:8:9: 8:10
-- StorageDead(_13); // scope 4 at $DIR/remove_storage_markers.rs:8:9: 8:10
-- StorageDead(_12); // scope 3 at $DIR/remove_storage_markers.rs:8:9: 8:10
-- StorageDead(_10); // scope 3 at $DIR/remove_storage_markers.rs:8:18: 8:19
-- StorageDead(_8); // scope 3 at $DIR/remove_storage_markers.rs:8:18: 8:19
-- StorageDead(_7); // scope 3 at $DIR/remove_storage_markers.rs:8:18: 8:19
-- StorageLive(_15); // scope 3 at $DIR/remove_storage_markers.rs:8:9: 8:10
- _15 = _6; // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
-- StorageLive(_16); // scope 5 at $DIR/remove_storage_markers.rs:8:20: 10:6
-- StorageLive(_17); // scope 5 at $DIR/remove_storage_markers.rs:9:16: 9:17
- _17 = _15; // scope 5 at $DIR/remove_storage_markers.rs:9:16: 9:17
- _1 = Add(_1, move _17); // scope 5 at $DIR/remove_storage_markers.rs:9:9: 9:17
-- StorageDead(_17); // scope 5 at $DIR/remove_storage_markers.rs:9:16: 9:17
- _16 = const (); // scope 5 at $DIR/remove_storage_markers.rs:8:20: 10:6
-- StorageDead(_16); // scope 5 at $DIR/remove_storage_markers.rs:10:5: 10:6
- _5 = const (); // scope 2 at $DIR/remove_storage_markers.rs:8:5: 10:6
-- StorageDead(_15); // scope 3 at $DIR/remove_storage_markers.rs:10:5: 10:6
+ _0 = const (); // scope 2 at $DIR/remove_storage_markers.rs:8:5: 10:6
+- StorageDead(_9); // scope 2 at $DIR/remove_storage_markers.rs:10:5: 10:6
+- StorageDead(_7); // scope 2 at $DIR/remove_storage_markers.rs:10:5: 10:6
- StorageDead(_6); // scope 2 at $DIR/remove_storage_markers.rs:10:5: 10:6
- goto -> bb1; // scope 2 at $DIR/remove_storage_markers.rs:8:5: 10:6
+- StorageDead(_4); // scope 1 at $DIR/remove_storage_markers.rs:10:5: 10:6
+- StorageDead(_2); // scope 1 at $DIR/remove_storage_markers.rs:10:5: 10:6
+- StorageDead(_1); // scope 0 at $DIR/remove_storage_markers.rs:11:1: 11:2
+ return; // scope 0 at $DIR/remove_storage_markers.rs:11:2: 11:2
}
bb4: {
-- StorageDead(_18); // scope 7 at $DIR/remove_storage_markers.rs:8:14: 8:19
-- StorageDead(_9); // scope 3 at $DIR/remove_storage_markers.rs:8:18: 8:19
- _11 = discriminant(_8); // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
- switchInt(move _11) -> [0_isize: bb2, otherwise: bb3]; // scope 3 at $DIR/remove_storage_markers.rs:8:14: 8:19
+- StorageDead(_14); // scope 5 at $DIR/remove_storage_markers.rs:8:14: 8:19
+- StorageDead(_8); // scope 2 at $DIR/remove_storage_markers.rs:8:18: 8:19
+ _10 = discriminant(_7); // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
+ switchInt(move _10) -> [0_isize: bb3, otherwise: bb2]; // scope 2 at $DIR/remove_storage_markers.rs:8:14: 8:19
}
}
5| 1|
6| 1| let mut x = 0;
7| 11| for _ in 0..10 {
- ^10
8| 10| match is_true {
9| | true => {
10| 10| continue;
16| 0| x = 3;
17| | }
18| 11| for _ in 0..10 {
- ^10
19| 10| match is_true {
20| 0| false => {
21| 0| x = 1;
27| 0| x = 3;
28| | }
29| 11| for _ in 0..10 {
- ^10
30| 10| match is_true {
31| 10| true => {
32| 10| x = 1;
38| 10| x = 3;
39| | }
40| 11| for _ in 0..10 {
- ^10
41| 10| if is_true {
42| 10| continue;
43| 0| }
44| 0| x = 3;
45| | }
46| 11| for _ in 0..10 {
- ^10
47| 10| match is_true {
48| 0| false => {
49| 0| x = 1;
39| 30|}
40| |
41| 6|fn display<T: Display>(xs: &[T]) {
- 42| 18| for x in xs {
+ 42| 24| for x in xs {
+ ^18
43| 18| print!("{}", x);
44| 18| }
45| 6| println!();
16| 0| } else {
17| 0| }
18| |
- 19| 10| for i in 0..10 {
+ 19| 11| for i in 0..10 {
+ ^10
20| 10| if true {
21| 10| if false {
22| 0| while true {}
41| 1| write!(f, "cool")?;
^0
42| | }
- 43| 10| for i in 0..10 {
+ 43| 11| for i in 0..10 {
+ ^10
44| 10| if false {
45| 0| } else {
46| 10| if false {
^0
13| |
14| | for
- 15| 2| _
+ 15| | _
16| | in
17| 3| 0..2
18| | {
14| 1| countdown = 10
15| | ;
16| | for
- 17| 6| _
+ 17| | _
18| | in
19| 6| 0..10
20| | {
63| 1| countdown = 10
64| | ;
65| | for
- 66| 6| _
+ 66| | _
67| | in
68| 6| 0..10
69| | {
--- /dev/null
+goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
+
+// Set the theme to light.
+local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
+// We reload the page so the local storage settings are being used.
+reload:
+
+assert-css: ("#toggle-all-docs", {"color": "rgba(0, 0, 0, 0)"})
+assert-css: (".fqn .in-band a:nth-of-type(1)", {"color": "rgba(0, 0, 0, 0)"})
+assert-css: (".fqn .in-band a:nth-of-type(2)", {"color": "rgba(0, 0, 0, 0)"})
+assert-css: (".srclink", {"color": "rgba(0, 0, 0, 0)"})
+assert-css: (".srclink", {"color": "rgba(0, 0, 0, 0)"})
+
+assert-css: ("#top-doc-prose-title", {"color": "rgba(0, 0, 0, 0)"})
+
+assert-css: (".sidebar a", {"color": "rgba(0, 0, 0, 0)"})
+assert-css: (".in-band a", {"color": "rgba(0, 0, 0, 0)"})
-// This test check that headers (a) have the correct heading level, (b) are the right size,
+// This test checks that headers (a) have the correct heading level, (b) are the right size,
// and (c) have the correct underlining (or absence of underlining).
// The sizes may change as design changes, but try to make sure a lower header is never bigger than
// its parent headers. Also make sure lower headers don't have underlines when their parents lack
assert-css: ("h2#variants", {"font-size": "22.4px"})
assert-css: ("h2#variants", {"border-bottom-width": "1px"})
-assert-css: ("h3#none-prose-title", {"font-size": "20.8px"})
-assert-css: ("h3#none-prose-title", {"border-bottom-width": "0px"})
-assert-css: ("h4#none-prose-sub-heading", {"font-size": "16px"})
-assert-css: ("h4#none-prose-sub-heading", {"border-bottom-width": "0px"})
-
-assert-css: ("h3#wrapped-prose-title", {"font-size": "20.8px"})
-assert-css: ("h3#wrapped-prose-title", {"border-bottom-width": "0px"})
-assert-css: ("h4#wrapped-prose-sub-heading", {"font-size": "16px"})
-assert-css: ("h4#wrapped-prose-sub-heading", {"border-bottom-width": "0px"})
-
-assert-css: ("h4#wrapped0-prose-title", {"font-size": "16px"})
-assert-css: ("h4#wrapped0-prose-title", {"border-bottom-width": "0px"})
-assert-css: ("h5#wrapped0-prose-sub-heading", {"font-size": "16px"})
-assert-css: ("h5#wrapped0-prose-sub-heading", {"border-bottom-width": "0px"})
-
-assert-css: ("h4#structy-prose-title", {"font-size": "16px"})
-assert-css: ("h4#structy-prose-title", {"border-bottom-width": "0px"})
-assert-css: ("h5#structy-prose-sub-heading", {"font-size": "16px"})
-assert-css: ("h5#structy-prose-sub-heading", {"border-bottom-width": "0px"})
+assert-css: ("h4#none-prose-title", {"font-size": "16px"})
+assert-css: ("h4#none-prose-title", {"border-bottom-width": "0px"})
+assert-css: ("h5#none-prose-sub-heading", {"font-size": "16px"})
+assert-css: ("h5#none-prose-sub-heading", {"border-bottom-width": "0px"})
+
+assert-css: ("h4#wrapped-prose-title", {"font-size": "16px"})
+assert-css: ("h4#wrapped-prose-title", {"border-bottom-width": "0px"})
+assert-css: ("h5#wrapped-prose-sub-heading", {"font-size": "16px"})
+assert-css: ("h5#wrapped-prose-sub-heading", {"border-bottom-width": "0px"})
+
+assert-css: ("h5#wrapped0-prose-title", {"font-size": "16px"})
+assert-css: ("h5#wrapped0-prose-title", {"border-bottom-width": "0px"})
+assert-css: ("h6#wrapped0-prose-sub-heading", {"font-size": "15.2px"})
+assert-css: ("h6#wrapped0-prose-sub-heading", {"border-bottom-width": "0px"})
+
+assert-css: ("h5#structy-prose-title", {"font-size": "16px"})
+assert-css: ("h5#structy-prose-title", {"border-bottom-width": "0px"})
+assert-css: ("h6#structy-prose-sub-heading", {"font-size": "15.2px"})
+assert-css: ("h6#structy-prose-sub-heading", {"border-bottom-width": "0px"})
assert-css: ("h2#implementations", {"font-size": "22.4px"})
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})
}
impl Foo {
+ /// Some documentation
+ /// # A Heading
pub fn a_method(&self) {}
}
--- /dev/null
+// This test ensures that clicking on a method summary, but not on the "[-]",
+// doesn't toggle the <details>.
+goto: file://|DOC_PATH|/test_docs/struct.Foo.html
+assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""})
+click: "h4.code-header" // This is the position of "pub" in "pub fn a_method"
+assert-attribute: (".impl-items .rustdoc-toggle", {"open": ""})
+click: ".impl-items .rustdoc-toggle summary::before" // This is the position of "[-]" next to that pub fn.
+assert-attribute-false: (".impl-items .rustdoc-toggle", {"open": ""})
&raw const $place
}
+pub macro addr_of_crate($place:expr) {
+ &raw const $place
+}
+
+pub macro addr_of_super($place:expr) {
+ &raw const $place
+}
+
pub macro addr_of_self($place:expr) {
&raw const $place
}
-pub macro addr_of_crate($place:expr) {
+pub macro addr_of_local($place:expr) {
&raw const $place
}
pub struct Foo;
-pub struct FooSelf;
pub struct FooCrate;
+pub struct FooSuper;
+pub struct FooSelf;
+pub struct FooLocal;
pub enum Bar { Foo, }
-pub enum BarSelf { Foo, }
pub enum BarCrate { Foo, }
+pub enum BarSuper { Foo, }
+pub enum BarSelf { Foo, }
+pub enum BarLocal { Foo, }
pub fn foo() {}
-pub fn foo_self() {}
pub fn foo_crate() {}
+pub fn foo_super() {}
+pub fn foo_self() {}
+pub fn foo_local() {}
pub type Type = i32;
-pub type TypeSelf = i32;
pub type TypeCrate = i32;
+pub type TypeSuper = i32;
+pub type TypeSelf = i32;
+pub type TypeLocal = i32;
pub union Union {
a: i8,
b: i8,
}
+pub union UnionCrate {
+ a: i8,
+ b: i8,
+}
+pub union UnionSuper {
+ a: i8,
+ b: i8,
+}
pub union UnionSelf {
a: i8,
b: i8,
}
-pub union UnionCrate {
+pub union UnionLocal {
a: i8,
b: i8,
}
--- /dev/null
+#![crate_name = "foo"]
+// @has foo/enum.Token.html
+/// A token!
+/// # First
+/// Some following text...
+// @has - '//h2[@id="first"]' "First"
+pub enum Token {
+ /// A declaration!
+ /// # Variant-First
+ /// Some following text...
+ // @has - '//h4[@id="variant-first"]' "Variant-First"
+ Declaration {
+ /// A version!
+ /// # Variant-Field-First
+ /// Some following text...
+ // @has - '//h5[@id="variant-field-first"]' "Variant-Field-First"
+ version: String,
+ },
+ /// A Zoople!
+ /// # Variant-First
+ Zoople(
+ // @has - '//h5[@id="variant-tuple-field-first"]' "Variant-Tuple-Field-First"
+ /// Zoople's first variant!
+ /// # Variant-Tuple-Field-First
+ /// Some following text...
+ usize,
+ ),
+ /// Unfinished business!
+ /// # Non-Exhaustive-First
+ /// Some following text...
+ // @has - '//h4[@id="non-exhaustive-first"]' "Non-Exhaustive-First"
+ #[non_exhaustive]
+ Unfinished {
+ /// This is x.
+ /// # X-First
+ /// Some following text...
+ // @has - '//h5[@id="x-first"]' "X-First"
+ x: usize,
+ },
+}
// @has 'foo/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place : expr) {'
pub use reexports::addr_of;
-// @has 'foo/macro.addr_of_crate.html' '//*[@class="docblock item-decl"]' 'pub(crate) macro addr_of_crate($place : expr) {'
+// @!has 'foo/macro.addr_of_crate.html'
pub(crate) use reexports::addr_of_crate;
-// @has 'foo/macro.addr_of_self.html' '//*[@class="docblock item-decl"]' 'pub(crate) macro addr_of_self($place : expr) {'
+// @!has 'foo/macro.addr_of_self.html'
pub(self) use reexports::addr_of_self;
+// @!has 'foo/macro.addr_of_local.html'
+use reexports::addr_of_local;
// @has 'foo/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;'
pub use reexports::Foo;
-// @has 'foo/struct.FooCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) struct FooCrate;'
+// @!has 'foo/struct.FooCrate.html'
pub(crate) use reexports::FooCrate;
-// @has 'foo/struct.FooSelf.html' '//*[@class="docblock item-decl"]' 'pub(crate) struct FooSelf;'
+// @!has 'foo/struct.FooSelf.html'
pub(self) use reexports::FooSelf;
+// @!has 'foo/struct.FooLocal.html'
+use reexports::FooLocal;
// @has 'foo/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {'
pub use reexports::Bar;
-// @has 'foo/enum.BarCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) enum BarCrate {'
+// @!has 'foo/enum.BarCrate.html'
pub(crate) use reexports::BarCrate;
-// @has 'foo/enum.BarSelf.html' '//*[@class="docblock item-decl"]' 'pub(crate) enum BarSelf {'
+// @!has 'foo/enum.BarSelf.html'
pub(self) use reexports::BarSelf;
+// @!has 'foo/enum.BarLocal.html'
+use reexports::BarLocal;
// @has 'foo/fn.foo.html' '//*[@class="rust fn"]' 'pub fn foo()'
pub use reexports::foo;
-// @has 'foo/fn.foo_crate.html' '//*[@class="rust fn"]' 'pub(crate) fn foo_crate()'
+// @!has 'foo/fn.foo_crate.html'
pub(crate) use reexports::foo_crate;
-// @has 'foo/fn.foo_self.html' '//*[@class="rust fn"]' 'pub(crate) fn foo_self()'
+// @!has 'foo/fn.foo_self.html'
pub(self) use reexports::foo_self;
+// @!has 'foo/fn.foo_local.html'
+use reexports::foo_local;
// @has 'foo/type.Type.html' '//*[@class="rust typedef"]' 'pub type Type ='
pub use reexports::Type;
-// @has 'foo/type.TypeCrate.html' '//*[@class="rust typedef"]' 'pub(crate) type TypeCrate ='
+// @!has 'foo/type.TypeCrate.html'
pub(crate) use reexports::TypeCrate;
-// @has 'foo/type.TypeSelf.html' '//*[@class="rust typedef"]' 'pub(crate) type TypeSelf ='
+// @!has 'foo/type.TypeSelf.html'
pub(self) use reexports::TypeSelf;
+// @!has 'foo/type.TypeLocal.html'
+use reexports::TypeLocal;
// @has 'foo/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {'
pub use reexports::Union;
-// @has 'foo/union.UnionCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) union UnionCrate {'
+// @!has 'foo/union.UnionCrate.html'
pub(crate) use reexports::UnionCrate;
-// @has 'foo/union.UnionSelf.html' '//*[@class="docblock item-decl"]' 'pub(crate) union UnionSelf {'
+// @!has 'foo/union.UnionSelf.html'
pub(self) use reexports::UnionSelf;
+// @!has 'foo/union.UnionLocal.html'
+use reexports::UnionLocal;
-pub mod foo {
- // @!has 'foo/foo/union.Union.html'
- use crate::reexports::Union;
+pub mod outer {
+ pub mod inner {
+ // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place : expr) {'
+ pub use reexports::addr_of;
+ // @has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="docblock item-decl"]' 'pub(crate) macro addr_of_crate($place : expr) {'
+ pub(crate) use reexports::addr_of_crate;
+ // @has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="docblock item-decl"]' 'pub(in outer) macro addr_of_super($place : expr) {'
+ pub(super) use reexports::addr_of_super;
+ // @!has 'foo/outer/inner/macro.addr_of_self.html'
+ pub(self) use reexports::addr_of_self;
+ // @!has 'foo/outer/inner/macro.addr_of_local.html'
+ use reexports::addr_of_local;
+
+ // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;'
+ pub use reexports::Foo;
+ // @has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) struct FooCrate;'
+ pub(crate) use reexports::FooCrate;
+ // @has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) struct FooSuper;'
+ pub(super) use reexports::FooSuper;
+ // @!has 'foo/outer/inner/struct.FooSelf.html'
+ pub(self) use reexports::FooSelf;
+ // @!has 'foo/outer/inner/struct.FooLocal.html'
+ use reexports::FooLocal;
+
+ // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {'
+ pub use reexports::Bar;
+ // @has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) enum BarCrate {'
+ pub(crate) use reexports::BarCrate;
+ // @has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) enum BarSuper {'
+ pub(super) use reexports::BarSuper;
+ // @!has 'foo/outer/inner/enum.BarSelf.html'
+ pub(self) use reexports::BarSelf;
+ // @!has 'foo/outer/inner/enum.BarLocal.html'
+ use reexports::BarLocal;
+
+ // @has 'foo/outer/inner/fn.foo.html' '//*[@class="rust fn"]' 'pub fn foo()'
+ pub use reexports::foo;
+ // @has 'foo/outer/inner/fn.foo_crate.html' '//*[@class="rust fn"]' 'pub(crate) fn foo_crate()'
+ pub(crate) use reexports::foo_crate;
+ // @has 'foo/outer/inner/fn.foo_super.html' '//*[@class="rust fn"]' 'pub(in outer) fn foo_super()'
+ pub(super) use::reexports::foo_super;
+ // @!has 'foo/outer/inner/fn.foo_self.html'
+ pub(self) use reexports::foo_self;
+ // @!has 'foo/outer/inner/fn.foo_local.html'
+ use reexports::foo_local;
+
+ // @has 'foo/outer/inner/type.Type.html' '//*[@class="rust typedef"]' 'pub type Type ='
+ pub use reexports::Type;
+ // @has 'foo/outer/inner/type.TypeCrate.html' '//*[@class="rust typedef"]' 'pub(crate) type TypeCrate ='
+ pub(crate) use reexports::TypeCrate;
+ // @has 'foo/outer/inner/type.TypeSuper.html' '//*[@class="rust typedef"]' 'pub(in outer) type TypeSuper ='
+ pub(super) use reexports::TypeSuper;
+ // @!has 'foo/outer/inner/type.TypeSelf.html'
+ pub(self) use reexports::TypeSelf;
+ // @!has 'foo/outer/inner/type.TypeLocal.html'
+ use reexports::TypeLocal;
+
+ // @has 'foo/outer/inner/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {'
+ pub use reexports::Union;
+ // @has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="docblock item-decl"]' 'pub(crate) union UnionCrate {'
+ pub(crate) use reexports::UnionCrate;
+ // @has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="docblock item-decl"]' 'pub(in outer) union UnionSuper {'
+ pub(super) use reexports::UnionSuper;
+ // @!has 'foo/outer/inner/union.UnionSelf.html'
+ pub(self) use reexports::UnionSelf;
+ // @!has 'foo/outer/inner/union.UnionLocal.html'
+ use reexports::UnionLocal;
+ }
+}
+
+mod re_re_exports {
+ // @!has 'foo/re_re_exports/union.Union.html'
+ use crate::reexports::Union;
}
pub(crate) use reexports::addr_of_crate;
// @!has 'foo/macro.addr_of_self.html'
pub(self) use reexports::addr_of_self;
+// @!has 'foo/macro.addr_of_local.html'
+use reexports::addr_of_local;
// @has 'foo/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;'
pub use reexports::Foo;
pub(crate) use reexports::FooCrate;
// @!has 'foo/struct.FooSelf.html'
pub(self) use reexports::FooSelf;
+// @!has 'foo/struct.FooLocal.html'
+use reexports::FooLocal;
// @has 'foo/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {'
pub use reexports::Bar;
pub(crate) use reexports::BarCrate;
// @!has 'foo/enum.BarSelf.html'
pub(self) use reexports::BarSelf;
+// @!has 'foo/enum.BarLocal.html'
+use reexports::BarLocal;
// @has 'foo/fn.foo.html' '//*[@class="rust fn"]' 'pub fn foo()'
pub use reexports::foo;
pub(crate) use reexports::foo_crate;
// @!has 'foo/fn.foo_self.html'
pub(self) use reexports::foo_self;
+// @!has 'foo/fn.foo_local.html'
+use reexports::foo_local;
// @has 'foo/type.Type.html' '//*[@class="rust typedef"]' 'pub type Type ='
pub use reexports::Type;
pub(crate) use reexports::TypeCrate;
// @!has 'foo/type.TypeSelf.html'
pub(self) use reexports::TypeSelf;
+// @!has 'foo/type.TypeLocal.html'
+use reexports::TypeLocal;
// @has 'foo/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {'
pub use reexports::Union;
pub(crate) use reexports::UnionCrate;
// @!has 'foo/union.UnionSelf.html'
pub(self) use reexports::UnionSelf;
+// @!has 'foo/union.UnionLocal.html'
+use reexports::UnionLocal;
+
+pub mod outer {
+ pub mod inner {
+ // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="docblock item-decl"]' 'pub macro addr_of($place : expr) {'
+ pub use reexports::addr_of;
+ // @!has 'foo/outer/inner/macro.addr_of_crate.html'
+ pub(crate) use reexports::addr_of_crate;
+ // @!has 'foo/outer/inner/macro.addr_of_super.html'
+ pub(super) use reexports::addr_of_super;
+ // @!has 'foo/outer/inner/macro.addr_of_self.html'
+ pub(self) use reexports::addr_of_self;
+ // @!has 'foo/outer/inner/macro.addr_of_local.html'
+ use reexports::addr_of_local;
+
+ // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="docblock item-decl"]' 'pub struct Foo;'
+ pub use reexports::Foo;
+ // @!has 'foo/outer/inner/struct.FooCrate.html'
+ pub(crate) use reexports::FooCrate;
+ // @!has 'foo/outer/inner/struct.FooSuper.html'
+ pub(super) use reexports::FooSuper;
+ // @!has 'foo/outer/inner/struct.FooSelf.html'
+ pub(self) use reexports::FooSelf;
+ // @!has 'foo/outer/inner/struct.FooLocal.html'
+ use reexports::FooLocal;
+
+ // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="docblock item-decl"]' 'pub enum Bar {'
+ pub use reexports::Bar;
+ // @!has 'foo/outer/inner/enum.BarCrate.html'
+ pub(crate) use reexports::BarCrate;
+ // @!has 'foo/outer/inner/enum.BarSuper.html'
+ pub(super) use reexports::BarSuper;
+ // @!has 'foo/outer/inner/enum.BarSelf.html'
+ pub(self) use reexports::BarSelf;
+ // @!has 'foo/outer/inner/enum.BarLocal.html'
+ use reexports::BarLocal;
+
+ // @has 'foo/outer/inner/fn.foo.html' '//*[@class="rust fn"]' 'pub fn foo()'
+ pub use reexports::foo;
+ // @!has 'foo/outer/inner/fn.foo_crate.html'
+ pub(crate) use reexports::foo_crate;
+ // @!has 'foo/outer/inner/fn.foo_super.html'
+ pub(super) use::reexports::foo_super;
+ // @!has 'foo/outer/inner/fn.foo_self.html'
+ pub(self) use reexports::foo_self;
+ // @!has 'foo/outer/inner/fn.foo_local.html'
+ use reexports::foo_local;
+
+ // @has 'foo/outer/inner/type.Type.html' '//*[@class="rust typedef"]' 'pub type Type ='
+ pub use reexports::Type;
+ // @!has 'foo/outer/inner/type.TypeCrate.html'
+ pub(crate) use reexports::TypeCrate;
+ // @!has 'foo/outer/inner/type.TypeSuper.html'
+ pub(super) use reexports::TypeSuper;
+ // @!has 'foo/outer/inner/type.TypeSelf.html'
+ pub(self) use reexports::TypeSelf;
+ // @!has 'foo/outer/inner/type.TypeLocal.html'
+ use reexports::TypeLocal;
+
+ // @has 'foo/outer/inner/union.Union.html' '//*[@class="docblock item-decl"]' 'pub union Union {'
+ pub use reexports::Union;
+ // @!has 'foo/outer/inner/union.UnionCrate.html'
+ pub(crate) use reexports::UnionCrate;
+ // @!has 'foo/outer/inner/union.UnionSuper.html'
+ pub(super) use reexports::UnionSuper;
+ // @!has 'foo/outer/inner/union.UnionSelf.html'
+ pub(self) use reexports::UnionSelf;
+ // @!has 'foo/outer/inner/union.UnionLocal.html'
+ use reexports::UnionLocal;
+ }
+}
// @has foo/enum.Bar.html
// @has - '//pre[@class="rust enum"]' 'BarVariant(String),'
-// @matches - '//*[@id="variant.BarVariant.fields"]/h3' '^Tuple Fields of BarVariant$'
+// @matches - '//*[@id="variant.BarVariant.fields"]/h4' '^Tuple Fields$'
// @has - '//*[@id="variant.BarVariant.field.0"]' '0: String'
// @has - '//*[@id="variant.BarVariant.fields"]//*[@class="docblock"]' 'Hello docs'
-// @matches - '//*[@id="variant.FooVariant.fields"]/h3' '^Fields of FooVariant$'
+// @matches - '//*[@id="variant.FooVariant.fields"]/h4' '^Fields$'
pub enum Bar {
BarVariant(
/// Hello docs
--- /dev/null
+// run-pass
+// only-x86_64-unknown-linux-gnu
+// revisions: ssp no-ssp
+// [ssp] compile-flags: -Z stack-protector=all
+// compile-flags: -C opt-level=2
+// compile-flags: -g
+
+use std::env;
+use std::process::{Command, ExitStatus};
+
+fn main() {
+ if env::args().len() == 1 {
+ // The test is initially run without arguments. Start the process again,
+ // this time *with* an argument; in this configuration, the test program
+ // will deliberately smash the stack.
+ let cur_argv0 = env::current_exe().unwrap();
+ let mut child = Command::new(&cur_argv0);
+ child.arg("stacksmash");
+
+ if cfg!(ssp) {
+ assert_stack_smash_prevented(&mut child);
+ } else {
+ assert_stack_smashed(&mut child);
+ }
+ } else {
+ vulnerable_function();
+ // If we return here the test is broken: it should either have called
+ // malicious_code() which terminates the process, or be caught by the
+ // stack check which also terminates the process.
+ panic!("TEST BUG: stack smash unsuccessful");
+ }
+}
+
+// Avoid inlining to make sure the return address is pushed to stack.
+#[inline(never)]
+fn vulnerable_function() {
+ let mut x = 5usize;
+ let stackaddr = &mut x as *mut usize;
+ let bad_code_ptr = malicious_code as usize;
+ // Overwrite the on-stack return address with the address of `malicious_code()`,
+ // thereby jumping to that function when returning from `vulnerable_function()`.
+ unsafe { fill(stackaddr, bad_code_ptr, 20); }
+}
+
+// Use an uninlined function with its own stack frame to make sure that we don't
+// clobber e.g. the counter or address local variable.
+#[inline(never)]
+unsafe fn fill(addr: *mut usize, val: usize, count: usize) {
+ let mut addr = addr;
+ for _ in 0..count {
+ *addr = val;
+ addr = addr.add(1);
+ }
+}
+
+// We jump to malicious_code() having wreaked havoc with the previous stack
+// frame and not setting up a new one. This function is therefore constrained,
+// e.g. both println!() and std::process::exit() segfaults if called. We
+// therefore keep the amount of work to a minimum by calling POSIX functions
+// directly.
+// The function is un-inlined just to make it possible to set a breakpoint here.
+#[inline(never)]
+fn malicious_code() {
+ let msg = [112u8, 119u8, 110u8, 101u8, 100u8, 33u8, 0u8]; // "pwned!\0" ascii
+ unsafe {
+ write(1, &msg as *const u8, msg.len());
+ _exit(0);
+ }
+}
+extern "C" {
+ fn write(fd: i32, buf: *const u8, count: usize) -> isize;
+ fn _exit(status: i32) -> !;
+}
+
+
+fn assert_stack_smash_prevented(cmd: &mut Command) {
+ let (status, stdout, stderr) = run(cmd);
+ assert!(!status.success());
+ assert!(stdout.is_empty());
+ assert!(stderr.contains("stack smashing detected"));
+}
+
+fn assert_stack_smashed(cmd: &mut Command) {
+ let (status, stdout, stderr) = run(cmd);
+ assert!(status.success());
+ assert!(stdout.contains("pwned!"));
+ assert!(stderr.is_empty());
+}
+
+
+fn run(cmd: &mut Command) -> (ExitStatus, String, String) {
+ let output = cmd.output().unwrap();
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ println!("status: {}", output.status);
+ println!("stdout: {}", stdout);
+ println!("stderr: {}", stderr);
+ (output.status, stdout.to_string(), stderr.to_string())
+}
+++ /dev/null
-#![allow(unused_imports)]
-
-mod foo {}
-
-use foo::{
- ::bar, //~ ERROR crate root in paths can only be used in start position
- super::bar, //~ ERROR `super` in paths can only be used in start position
- self::bar, //~ ERROR `self` in paths can only be used in start position
-};
-
-fn main() {}
+++ /dev/null
-error[E0433]: failed to resolve: crate root in paths can only be used in start position
- --> $DIR/absolute-paths-in-nested-use-groups.rs:6:5
- |
-LL | ::bar,
- | ^ crate root in paths can only be used in start position
-
-error[E0433]: failed to resolve: `super` in paths can only be used in start position
- --> $DIR/absolute-paths-in-nested-use-groups.rs:7:5
- |
-LL | super::bar,
- | ^^^^^ `super` in paths can only be used in start position
-
-error[E0433]: failed to resolve: `self` in paths can only be used in start position
- --> $DIR/absolute-paths-in-nested-use-groups.rs:8:5
- |
-LL | self::bar,
- | ^^^^ `self` in paths can only be used in start position
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0433`.
+++ /dev/null
-// run-pass
-
-#![allow(non_camel_case_types)]
-#![allow(dead_code)]
-
-struct pair<A,B> {
- a: A, b: B
-}
-
-trait Invokable<A> {
- fn f(&self) -> (A, u16);
-}
-
-struct Invoker<A> {
- a: A,
- b: u16,
-}
-
-impl<A:Clone> Invokable<A> for Invoker<A> {
- fn f(&self) -> (A, u16) {
- (self.a.clone(), self.b)
- }
-}
-
-fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
- Box::new(Invoker {
- a: a,
- b: b,
- }) as Box<dyn Invokable<A>+'static>
-}
-
-pub fn main() {
- let (a, b) = f(22_u64, 44u16).f();
- println!("a={} b={}", a, b);
- assert_eq!(a, 22u64);
- assert_eq!(b, 44u16);
-}
LL | static A: usize = 0;
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
-note: required by `std::alloc::GlobalAlloc::alloc`
- --> $SRC_DIR/core/src/alloc/global.rs:LL:COL
- |
-LL | unsafe fn alloc(&self, layout: Layout) -> *mut u8;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
LL | static A: usize = 0;
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
-note: required by `std::alloc::GlobalAlloc::dealloc`
- --> $SRC_DIR/core/src/alloc/global.rs:LL:COL
- |
-LL | unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
LL | static A: usize = 0;
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
-note: required by `std::alloc::GlobalAlloc::realloc`
- --> $SRC_DIR/core/src/alloc/global.rs:LL:COL
- |
-LL | unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
LL | static A: usize = 0;
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
|
-note: required by `std::alloc::GlobalAlloc::alloc_zeroed`
- --> $SRC_DIR/core/src/alloc/global.rs:LL:COL
- |
-LL | unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 4 previous errors
--- /dev/null
+// run-pass
+//
+
+
+static FOO: u8 = b'\xF0';
+static BAR: &'static [u8] = b"a\xF0\t";
+static BAR_FIXED: &'static [u8; 3] = b"a\xF0\t";
+static BAZ: &'static [u8] = br"a\n";
+
+pub fn main() {
+ let bar: &'static [u8] = b"a\xF0\t";
+ let bar_fixed: &'static [u8; 3] = b"a\xF0\t";
+
+ assert_eq!(b'a', 97u8);
+ assert_eq!(b'\n', 10u8);
+ assert_eq!(b'\r', 13u8);
+ assert_eq!(b'\t', 9u8);
+ assert_eq!(b'\\', 92u8);
+ assert_eq!(b'\'', 39u8);
+ assert_eq!(b'\"', 34u8);
+ assert_eq!(b'\0', 0u8);
+ assert_eq!(b'\xF0', 240u8);
+ assert_eq!(FOO, 240u8);
+
+ match 42 {
+ b'*' => {},
+ _ => panic!()
+ }
+
+ match 100 {
+ b'a' ..= b'z' => {},
+ _ => panic!()
+ }
+
+ let expected: &[_] = &[97u8, 10u8, 13u8, 9u8, 92u8, 39u8, 34u8, 0u8, 240u8];
+ assert_eq!(b"a\n\r\t\\\'\"\0\xF0", expected);
+ let expected: &[_] = &[97u8, 98u8];
+ assert_eq!(b"a\
+ b", expected);
+ let expected: &[_] = &[97u8, 240u8, 9u8];
+ assert_eq!(BAR, expected);
+ assert_eq!(BAR_FIXED, expected);
+ assert_eq!(bar, expected);
+ assert_eq!(bar_fixed, expected);
+
+ let val = &[97u8, 10u8];
+ match val {
+ b"a\n" => {},
+ _ => panic!(),
+ }
+
+ let buf = vec![97u8, 98, 99, 100];
+ assert_eq!(match &buf[0..3] {
+ b"def" => 1,
+ b"abc" => 2,
+ _ => 3
+ }, 2);
+
+ let expected: &[_] = &[97u8, 92u8, 110u8];
+ assert_eq!(BAZ, expected);
+ let expected: &[_] = &[97u8, 92u8, 110u8];
+ assert_eq!(br"a\n", expected);
+ assert_eq!(br"a\n", b"a\\n");
+ let expected: &[_] = &[97u8, 34u8, 35u8, 35u8, 98u8];
+ assert_eq!(br###"a"##b"###, expected);
+ assert_eq!(br###"a"##b"###, b"a\"##b");
+}
+++ /dev/null
-struct Foo;
-
-fn main() {
- let mut a = Foo;
- let ref b = Foo;
- a += *b; //~ Error: binary assignment operation `+=` cannot be applied to type `Foo`
-}
+++ /dev/null
-error[E0368]: binary assignment operation `+=` cannot be applied to type `Foo`
- --> $DIR/assignment-operator-unimplemented.rs:6:3
- |
-LL | a += *b;
- | -^^^^^^
- | |
- | cannot use `+=` on type `Foo`
- |
-note: an implementation of `AddAssign<_>` might be missing for `Foo`
- --> $DIR/assignment-operator-unimplemented.rs:1:1
- |
-LL | struct Foo;
- | ^^^^^^^^^^^ must implement `AddAssign<_>`
-note: the following trait must be implemented
- --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
- |
-LL | / pub trait AddAssign<Rhs = Self> {
-LL | | /// Performs the `+=` operation.
-LL | | ///
-LL | | /// # Example
-... |
-LL | | fn add_assign(&mut self, rhs: Rhs);
-LL | | }
- | |_^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0368`.
|
LL | const X: [i32; <i32 as Foo>::ID] = [0, 1, 2];
| ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32`
- |
-note: required by `Foo::ID`
- --> $DIR/associated-const-array-len.rs:2:5
- |
-LL | const ID: usize;
- | ^^^^^^^^^^^^^^^^
error: aborting due to previous error
|
= note: cannot satisfy `_: A`
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
-note: required by `A::C`
- --> $DIR/issue-63496.rs:2:5
- |
-LL | const C: usize;
- | ^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-63496.rs:4:33
|
= note: cannot satisfy `_: A`
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
-note: required by `A::C`
- --> $DIR/issue-63496.rs:2:5
- |
-LL | const C: usize;
- | ^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
|
= note: cannot satisfy `_: Bar`
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
-note: required by `Bar::X`
- --> $DIR/issue-48027.rs:2:5
- |
-LL | const X: usize;
- | ^^^^^^^^^^^^^^^
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-48027.rs:6:6
| ^^^^ `<<Self as Case1>::C as Iterator>::Item` cannot be sent between threads safely
|
= help: the trait `Send` is not implemented for `<<Self as Case1>::C as Iterator>::Item`
-note: required by a bound in `Send`
- --> $SRC_DIR/core/src/marker.rs:LL:COL
- |
-LL | / pub unsafe auto trait Send {
-LL | | // empty.
-LL | | }
- | |_^ required by this bound in `Send`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::C as Iterator>::Item: Send {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `<<Self as Case1>::C as Iterator>::Item` is not an iterator
|
= help: the trait `Iterator` is not implemented for `<<Self as Case1>::C as Iterator>::Item`
-note: required by a bound in `Iterator`
- --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- |
-LL | / pub trait Iterator {
-LL | | /// The type of the elements being iterated over.
-LL | | #[stable(feature = "rust1", since = "1.0.0")]
-LL | | type Item;
-... |
-LL | | }
-LL | | }
- | |_^ required by this bound in `Iterator`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::C as Iterator>::Item: Iterator {
| ^^^^ `<<Self as Case1>::C as Iterator>::Item` cannot be shared between threads safely
|
= help: the trait `Sync` is not implemented for `<<Self as Case1>::C as Iterator>::Item`
-note: required by a bound in `Sync`
- --> $SRC_DIR/core/src/marker.rs:LL:COL
- |
-LL | / pub unsafe auto trait Sync {
-LL | | // FIXME(estebank): once support to add notes in `rustc_on_unimplemented`
-LL | | // lands in beta, and it has been extended to check whether a closure is
-LL | | // anywhere in the requirement chain, extend it as such (#48534):
-... |
-LL | | // Empty
-LL | | }
- | |_^ required by this bound in `Sync`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::C as Iterator>::Item: Sync {
| ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
= help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
-note: required by a bound in `Debug`
- --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
- |
-LL | / pub trait Debug {
-LL | | /// Formats the value using the given formatter.
-LL | | ///
-LL | | /// # Examples
-... |
-LL | | fn fmt(&self, f: &mut Formatter<'_>) -> Result;
-LL | | }
- | |_^ required by this bound in `Debug`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::A as Iterator>::Item: Debug {
LL | pub trait Foo { type Out: Baz<Assoc: Default>; }
| ^^^^^^^ the trait `Default` is not implemented for `<<Self as Foo>::Out as Baz>::Assoc`
|
-note: required by a bound in `Default`
- --> $SRC_DIR/core/src/default.rs:LL:COL
- |
-LL | / pub trait Default: Sized {
-LL | | /// Returns the "default value" for a type.
-LL | | ///
-LL | | /// Default values are often some kind of initial value, identity value, or anything else that
-... |
-LL | | fn default() -> Self;
-LL | | }
- | |_^ required by this bound in `Default`
help: consider further restricting the associated type
|
LL | pub trait Foo where <<Self as Foo>::Out as Baz>::Assoc: Default { type Out: Baz<Assoc: Default>; }
| |
| required by a bound introduced by this call
|
-note: required by `ToInt::to_int`
- --> $DIR/associated-types-bound-failure.rs:6:5
- |
-LL | fn to_int(&self) -> isize;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider further restricting the associated type
|
LL | where G : GetToInt, <G as GetToInt>::R: ToInt
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
-note: required by a bound in `Get`
- --> $DIR/associated-types-for-unimpl-trait.rs:4:1
- |
-LL | trait Get {
- | ^^^^^^^^^ required by this bound in `Get`
help: consider further restricting `Self`
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
LL | fn uhoh<T>(foo: <T as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `T`
|
-note: required by a bound in `Get`
- --> $DIR/associated-types-no-suitable-bound.rs:1:1
- |
-LL | trait Get {
- | ^^^^^^^^^ required by this bound in `Get`
help: consider restricting type parameter `T`
|
LL | fn uhoh<T: Get>(foo: <T as Get>::Value) {}
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
-note: required by a bound in `Get`
- --> $DIR/associated-types-no-suitable-supertrait-2.rs:12:1
- |
-LL | trait Get {
- | ^^^^^^^^^ required by this bound in `Get`
help: consider further restricting `Self`
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
-note: required by a bound in `Get`
- --> $DIR/associated-types-no-suitable-supertrait.rs:12:1
- |
-LL | trait Get {
- | ^^^^^^^^^ required by this bound in `Get`
help: consider further restricting `Self`
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
|
LL | fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)`
- |
-note: required by a bound in `Get`
- --> $DIR/associated-types-no-suitable-supertrait.rs:12:1
- |
-LL | trait Get {
- | ^^^^^^^^^ required by this bound in `Get`
error: aborting due to 2 previous errors
LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value);
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`
|
-note: required by a bound in `Get`
- --> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:5:1
- |
-LL | trait Get {
- | ^^^^^^^^^ required by this bound in `Get`
help: consider further restricting `Self`
|
LL | fn okay<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get;
| ^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Foo`
-note: required by `Foo::bar`
- --> $DIR/associated-types-unconstrained.rs:5:5
- |
-LL | fn bar() -> isize;
- | ^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
|
LL | impl<'a> Visit for () where
| ^^^^^ ^^
-note: required by `Visit::visit`
- --> $DIR/issue-44153.rs:6:5
- |
-LL | fn visit() {}
- | ^^^^^^^^^^
error: aborting due to previous error
//~^ ERROR type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()`
accepts_trait(returns_opaque_foo());
- //~^ ERROR type mismatch resolving `<impl Trait+Foo as Trait>::Associated == ()`
+ //~^ ERROR type mismatch resolving `<impl Trait + Foo as Trait>::Associated == ()`
accepts_trait(returns_opaque_derived_foo());
- //~^ ERROR type mismatch resolving `<impl DerivedTrait+Foo as Trait>::Associated == ()`
+ //~^ ERROR type mismatch resolving `<impl DerivedTrait + Foo as Trait>::Associated == ()`
accepts_generic_trait(returns_opaque_generic());
//~^ ERROR type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()`
accepts_generic_trait(returns_opaque_generic_foo());
- //~^ ERROR type mismatch resolving `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated == ()`
+ //~^ ERROR type mismatch resolving `<impl GenericTrait<()> + Foo as GenericTrait<()>>::Associated == ()`
accepts_generic_trait(returns_opaque_generic_duplicate());
- //~^ ERROR type mismatch resolving `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated == ()`
+ //~^ ERROR type mismatch resolving `<impl GenericTrait<()> + GenericTrait<u8> as GenericTrait<()>>::Associated == ()`
}
LL | fn returns_opaque_derived() -> impl DerivedTrait<Associated = ()> + 'static {
| +++++++++++++++++
-error[E0271]: type mismatch resolving `<impl Trait+Foo as Trait>::Associated == ()`
+error[E0271]: type mismatch resolving `<impl Trait + Foo as Trait>::Associated == ()`
--> $DIR/issue-87261.rs:85:5
|
LL | fn returns_opaque_foo() -> impl Trait + Foo {
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
= note: expected unit type `()`
- found associated type `<impl Trait+Foo as Trait>::Associated`
+ found associated type `<impl Trait + Foo as Trait>::Associated`
note: required by a bound in `accepts_trait`
--> $DIR/issue-87261.rs:43:27
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
| ^^^^^^^^^^^^^^^ required by this bound in `accepts_trait`
-help: consider constraining the associated type `<impl Trait+Foo as Trait>::Associated` to `()`
+help: consider constraining the associated type `<impl Trait + Foo as Trait>::Associated` to `()`
|
LL | fn returns_opaque_foo() -> impl Trait<Associated = ()> + Foo {
| +++++++++++++++++
-error[E0271]: type mismatch resolving `<impl DerivedTrait+Foo as Trait>::Associated == ()`
+error[E0271]: type mismatch resolving `<impl DerivedTrait + Foo as Trait>::Associated == ()`
--> $DIR/issue-87261.rs:88:5
|
LL | fn returns_opaque_derived_foo() -> impl DerivedTrait + Foo {
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
= note: expected unit type `()`
- found associated type `<impl DerivedTrait+Foo as Trait>::Associated`
- = help: consider constraining the associated type `<impl DerivedTrait+Foo as Trait>::Associated` to `()`
+ found associated type `<impl DerivedTrait + Foo as Trait>::Associated`
+ = help: consider constraining the associated type `<impl DerivedTrait + Foo as Trait>::Associated` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `accepts_trait`
--> $DIR/issue-87261.rs:43:27
LL | fn returns_opaque_generic() -> impl GenericTrait<(), Associated = ()> + 'static {
| +++++++++++++++++
-error[E0271]: type mismatch resolving `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated == ()`
+error[E0271]: type mismatch resolving `<impl GenericTrait<()> + Foo as GenericTrait<()>>::Associated == ()`
--> $DIR/issue-87261.rs:94:5
|
LL | fn returns_opaque_generic_foo() -> impl GenericTrait<()> + Foo {
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
= note: expected unit type `()`
- found associated type `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated`
+ found associated type `<impl GenericTrait<()> + Foo as GenericTrait<()>>::Associated`
note: required by a bound in `accepts_generic_trait`
--> $DIR/issue-87261.rs:44:46
|
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
| ^^^^^^^^^^^^^^^ required by this bound in `accepts_generic_trait`
-help: consider constraining the associated type `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated` to `()`
+help: consider constraining the associated type `<impl GenericTrait<()> + Foo as GenericTrait<()>>::Associated` to `()`
|
LL | fn returns_opaque_generic_foo() -> impl GenericTrait<(), Associated = ()> + Foo {
| +++++++++++++++++
-error[E0271]: type mismatch resolving `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated == ()`
+error[E0271]: type mismatch resolving `<impl GenericTrait<()> + GenericTrait<u8> as GenericTrait<()>>::Associated == ()`
--> $DIR/issue-87261.rs:97:5
|
LL | fn returns_opaque_generic_duplicate() -> impl GenericTrait<()> + GenericTrait<u8> {
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
= note: expected unit type `()`
- found associated type `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated`
- = help: consider constraining the associated type `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated` to `()`
+ found associated type `<impl GenericTrait<()> + GenericTrait<u8> as GenericTrait<()>>::Associated`
+ = help: consider constraining the associated type `<impl GenericTrait<()> + GenericTrait<u8> as GenericTrait<()>>::Associated` to `()`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: required by a bound in `accepts_generic_trait`
--> $DIR/issue-87261.rs:44:46
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:16:17
+ |
+LL | fn bar<'a, T>() where T: 'a {}
+ | --------------------------- fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>} defined here
+...
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
+ | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
+help: use parentheses to call this function
+ |
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
+ | ++
+
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:25:17
+ |
+LL | fn bar<'a, T>() where T: 'a {}
+ | --------------------------- fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>} defined here
+...
+LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
+ | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
+help: use parentheses to call this function
+ |
+LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
+ | ++
+
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:33:17
+ |
+LL | fn baz() {}
+ | -------- fn() {<i8 as Foo<'static, 'static, u8>>::baz} defined here
+...
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
+ | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
+help: use parentheses to call this function
+ |
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
+ | ++
+
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:41:17
+ |
+LL | fn foo<'z>() where &'z (): Sized {
+ | -------------------------------- fn() {foo::<'static>} defined here
+...
+LL | let x: () = foo::<'static>;
+ | -- ^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {foo::<'static>}`
+help: use parentheses to call this function
+ |
+LL | let x: () = foo::<'static>();
+ | ++
+
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+ --> $DIR/substs-ppaux.rs:49:5
+ |
+LL | <str as Foo<u8>>::bar;
+ | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `str`
+note: required because of the requirements on the impl of `Foo<'_, '_, u8>` for `str`
+ --> $DIR/substs-ppaux.rs:11:17
+ |
+LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
+ | ^^^^^^^^^^^^^^ ^
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.
--- /dev/null
+//
+// revisions: verbose normal
+//
+//[verbose] compile-flags: -Z verbose
+
+trait Foo<'b, 'c, S=u32> {
+ fn bar<'a, T>() where T: 'a {}
+ fn baz() {}
+}
+
+impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
+
+fn main() {}
+
+fn foo<'z>() where &'z (): Sized {
+ let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
+ //[verbose]~^ ERROR mismatched types
+ //[verbose]~| expected unit type `()`
+ //[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
+ //[normal]~^^^^ ERROR mismatched types
+ //[normal]~| expected unit type `()`
+ //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
+
+
+ let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
+ //[verbose]~^ ERROR mismatched types
+ //[verbose]~| expected unit type `()`
+ //[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
+ //[normal]~^^^^ ERROR mismatched types
+ //[normal]~| expected unit type `()`
+ //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
+
+ let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
+ //[verbose]~^ ERROR mismatched types
+ //[verbose]~| expected unit type `()`
+ //[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
+ //[normal]~^^^^ ERROR mismatched types
+ //[normal]~| expected unit type `()`
+ //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
+
+ let x: () = foo::<'static>;
+ //[verbose]~^ ERROR mismatched types
+ //[verbose]~| expected unit type `()`
+ //[verbose]~| found fn item `fn() {foo::<ReStatic>}`
+ //[normal]~^^^^ ERROR mismatched types
+ //[normal]~| expected unit type `()`
+ //[normal]~| found fn item `fn() {foo::<'static>}`
+
+ <str as Foo<u8>>::bar;
+ //[verbose]~^ ERROR the size for values of type
+ //[normal]~^^ ERROR the size for values of type
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:16:17
+ |
+LL | fn bar<'a, T>() where T: 'a {}
+ | --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>} defined here
+...
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
+ | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
+help: use parentheses to call this function
+ |
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
+ | ++
+
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:25:17
+ |
+LL | fn bar<'a, T>() where T: 'a {}
+ | --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>} defined here
+...
+LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
+ | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
+help: use parentheses to call this function
+ |
+LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
+ | ++
+
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:33:17
+ |
+LL | fn baz() {}
+ | -------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz} defined here
+...
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
+ | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
+help: use parentheses to call this function
+ |
+LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
+ | ++
+
+error[E0308]: mismatched types
+ --> $DIR/substs-ppaux.rs:41:17
+ |
+LL | fn foo<'z>() where &'z (): Sized {
+ | -------------------------------- fn() {foo::<ReStatic>} defined here
+...
+LL | let x: () = foo::<'static>;
+ | -- ^^^^^^^^^^^^^^ expected `()`, found fn item
+ | |
+ | expected due to this
+ |
+ = note: expected unit type `()`
+ found fn item `fn() {foo::<ReStatic>}`
+help: use parentheses to call this function
+ |
+LL | let x: () = foo::<'static>();
+ | ++
+
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+ --> $DIR/substs-ppaux.rs:49:5
+ |
+LL | <str as Foo<u8>>::bar;
+ | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ |
+ = help: the trait `Sized` is not implemented for `str`
+note: required because of the requirements on the impl of `Foo<'_#0r, '_#1r, u8>` for `str`
+ --> $DIR/substs-ppaux.rs:11:17
+ |
+LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
+ | ^^^^^^^^^^^^^^ ^
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0277, E0308.
+For more information about an error, try `rustc --explain E0277`.
LL | assert_send(local_dropped_before_await());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `local_dropped_before_await` is not `Send`
|
- = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>`
+ = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>`
note: future is not `Send` as this value is used across an await
--> $DIR/async-fn-nonsend.rs:24:5
|
LL | assert_send(non_send_temporary_in_match());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send`
|
- = help: within `impl Future`, the trait `Send` is not implemented for `Rc<()>`
+ = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Rc<()>`
note: future is not `Send` as this value is used across an await
--> $DIR/async-fn-nonsend.rs:33:20
|
LL | async fn make_u32() -> u32 {
| ^^^ checked the `Output` of this `async fn`, found opaque type
= note: expected type `u32`
- found opaque type `impl Future`
+ found opaque type `impl Future<Output = u32>`
help: consider `await`ing on the `Future`
|
LL | take_u32(x.await)
|
LL | async fn two() {}
| ^ checked the `Output` of this `async fn`, found opaque type
- = note: expected opaque type `impl Future` (opaque type at <$DIR/generator-desc.rs:5:16>)
- found opaque type `impl Future` (opaque type at <$DIR/generator-desc.rs:6:16>)
+ = note: expected opaque type `impl Future<Output = ()>` (opaque type at <$DIR/generator-desc.rs:5:16>)
+ found opaque type `impl Future<Output = ()>` (opaque type at <$DIR/generator-desc.rs:6:16>)
= help: consider `await`ing on both `Future`s
= note: distinct uses of `impl Trait` result in different opaque types
async fn bar() -> Result<(), ()> {
foo()?; //~ ERROR the `?` operator can only be applied to values that implement `Try`
- //~^ NOTE the `?` operator cannot be applied to type `impl Future`
- //~| HELP the trait `Try` is not implemented for `impl Future`
- //~| NOTE required by `branch`
+ //~^ NOTE the `?` operator cannot be applied to type `impl Future<Output = Result<(), ()>>`
+ //~| HELP the trait `Try` is not implemented for `impl Future<Output = Result<(), ()>>`
//~| HELP consider `await`ing on the `Future`
//~| NOTE in this expansion of desugaring of operator `?`
//~| NOTE in this expansion of desugaring of operator `?`
//~| NOTE in this expansion of desugaring of operator `?`
- //~| NOTE in this expansion of desugaring of operator `?`
Ok(())
}
t?; //~ ERROR the `?` operator can only be applied to values that implement `Try`
//~^ NOTE the `?` operator cannot be applied to type `T`
//~| HELP the trait `Try` is not implemented for `T`
- //~| NOTE required by `branch`
//~| HELP consider `await`ing on the `Future`
//~| NOTE in this expansion of desugaring of operator `?`
//~| NOTE in this expansion of desugaring of operator `?`
//~| NOTE in this expansion of desugaring of operator `?`
- //~| NOTE in this expansion of desugaring of operator `?`
let _: i32 = tuple().0; //~ ERROR no field `0`
//~| NOTE field not available in `impl Future`
struct_().method(); //~ ERROR no method named
- //~^ NOTE method not found in `impl Future`
+ //~^ NOTE method not found in `impl Future<Output = Struct>`
//~| HELP consider `await`ing on the `Future`
Ok(())
}
match tuple() { //~ HELP consider `await`ing on the `Future`
Tuple(_) => {} //~ ERROR mismatched types
//~^ NOTE expected opaque type, found struct `Tuple`
- //~| NOTE expected opaque type `impl Future`
+ //~| NOTE expected opaque type `impl Future<Output = Tuple>`
}
}
--> $DIR/issue-61076.rs:42:5
|
LL | foo()?;
- | ^^^^^^ the `?` operator cannot be applied to type `impl Future`
+ | ^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = Result<(), ()>>`
|
- = help: the trait `Try` is not implemented for `impl Future`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: the trait `Try` is not implemented for `impl Future<Output = Result<(), ()>>`
help: consider `await`ing on the `Future`
|
LL | foo().await?;
| ++++++
error[E0277]: the `?` operator can only be applied to values that implement `Try`
- --> $DIR/issue-61076.rs:67:5
+ --> $DIR/issue-61076.rs:65:5
|
LL | t?;
| ^^ the `?` operator cannot be applied to type `T`
|
= help: the trait `Try` is not implemented for `T`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider `await`ing on the `Future`
|
LL | t.await?;
| ++++++
-error[E0609]: no field `0` on type `impl Future`
- --> $DIR/issue-61076.rs:78:26
+error[E0609]: no field `0` on type `impl Future<Output = Tuple>`
+ --> $DIR/issue-61076.rs:74:26
|
LL | let _: i32 = tuple().0;
| ^ field not available in `impl Future`, but it is available in its `Output`
LL | let _: i32 = tuple().await.0;
| ++++++
-error[E0609]: no field `a` on type `impl Future`
- --> $DIR/issue-61076.rs:82:28
+error[E0609]: no field `a` on type `impl Future<Output = Struct>`
+ --> $DIR/issue-61076.rs:78:28
|
LL | let _: i32 = struct_().a;
| ^ field not available in `impl Future`, but it is available in its `Output`
LL | let _: i32 = struct_().await.a;
| ++++++
-error[E0599]: no method named `method` found for opaque type `impl Future` in the current scope
- --> $DIR/issue-61076.rs:86:15
+error[E0599]: no method named `method` found for opaque type `impl Future<Output = Struct>` in the current scope
+ --> $DIR/issue-61076.rs:82:15
|
LL | struct_().method();
- | ^^^^^^ method not found in `impl Future`
+ | ^^^^^^ method not found in `impl Future<Output = Struct>`
|
help: consider `await`ing on the `Future` and calling the method on its `Output`
|
| ++++++
error[E0308]: mismatched types
- --> $DIR/issue-61076.rs:94:9
+ --> $DIR/issue-61076.rs:90:9
|
LL | Tuple(_) => {}
| ^^^^^^^^ expected opaque type, found struct `Tuple`
|
note: while checking the return type of the `async fn`
- --> $DIR/issue-61076.rs:58:21
+ --> $DIR/issue-61076.rs:56:21
|
LL | async fn tuple() -> Tuple {
| ^^^^^ checked the `Output` of this `async fn`, expected opaque type
- = note: expected opaque type `impl Future`
+ = note: expected opaque type `impl Future<Output = Tuple>`
found struct `Tuple`
help: consider `await`ing on the `Future`
|
LL | is_sync(bar());
| ^^^^^ future returned by `bar` is not `Sync`
|
- = help: within `impl Future`, the trait `Sync` is not implemented for `Foo`
+ = help: within `impl Future<Output = ()>`, the trait `Sync` is not implemented for `Foo`
note: future is not `Sync` as this value is used across an await
--> $DIR/issue-64130-1-sync.rs:15:5
|
LL | is_send(bar());
| ^^^^^ future returned by `bar` is not `Send`
|
- = help: within `impl Future`, the trait `Send` is not implemented for `Foo`
+ = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `Foo`
note: future is not `Send` as this value is used across an await
--> $DIR/issue-64130-2-send.rs:15:5
|
// This tests the the unspecialized async-await-specific error when futures don't implement an
// auto trait (which is not Send or Sync) due to some type that was captured.
-auto trait Qux { }
+auto trait Qux {}
struct Foo;
impl !Qux for Foo {}
-fn is_qux<T: Qux>(t: T) { }
+fn is_qux<T: Qux>(t: T) {}
async fn bar() {
let x = Foo;
baz().await;
}
-async fn baz() { }
+async fn baz() {}
fn main() {
is_qux(bar());
- //~^ ERROR the trait bound `Foo: Qux` is not satisfied in `impl Future`
+ //~^ ERROR the trait bound `Foo: Qux` is not satisfied in `impl Future<Output = ()>`
}
-error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future`
+error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future<Output = ()>`
--> $DIR/issue-64130-3-other.rs:24:12
|
LL | async fn bar() {
- | - within this `impl Future`
+ | - within this `impl Future<Output = ()>`
...
LL | is_qux(bar());
- | ^^^^^ within `impl Future`, the trait `Qux` is not implemented for `Foo`
+ | ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo`
|
note: future does not implement `Qux` as this value is used across an await
--> $DIR/issue-64130-3-other.rs:18:5
note: required by a bound in `is_qux`
--> $DIR/issue-64130-3-other.rs:14:14
|
-LL | fn is_qux<T: Qux>(t: T) { }
+LL | fn is_qux<T: Qux>(t: T) {}
| ^^^ required by this bound in `is_qux`
error: aborting due to previous error
LL | is_send(foo());
| ^^^^^ future returned by `foo` is not `Send`
|
- = help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, u32>`
+ = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, u32>`
note: future is not `Send` as this value is used across an await
--> $DIR/issue-64130-non-send-future-diags.rs:17:5
|
--> $DIR/issue-68112.rs:31:17
|
LL | let _ = non_send_fut.await;
- | ^^^^^^^^^^^^ await occurs here on type `impl Future`, which is not `Send`
+ | ^^^^^^^^^^^^ await occurs here on type `impl Future<Output = Arc<RefCell<i32>>>`, which is not `Send`
note: required by a bound in `require_send`
--> $DIR/issue-68112.rs:11:25
|
--> $DIR/issue-68112.rs:40:17
|
LL | let _ = make_non_send_future1().await;
- | ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl Future`, which is not `Send`
+ | ^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `impl Future<Output = Arc<RefCell<i32>>>`, which is not `Send`
note: required by a bound in `require_send`
--> $DIR/issue-68112.rs:11:25
|
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:47:31: 47:36]`
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:47:31: 47:36]>`
= note: required because it appears within the type `impl Future`
- = note: required because it appears within the type `impl Future`
- = note: required because it appears within the type `impl Future`
- = note: required because it appears within the type `{ResumeTy, impl Future, (), i32, Ready<i32>}`
+ = note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>`
+ = note: required because it appears within the type `impl Future<Output = Arc<RefCell<i32>>>`
+ = note: required because it appears within the type `{ResumeTy, impl Future<Output = Arc<RefCell<i32>>>, (), i32, Ready<i32>}`
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:55:26: 59:6]`
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:55:26: 59:6]>`
= note: required because it appears within the type `impl Future`
| ^^^^^^^^ `()` is not a future
|
= help: the trait `Future` is not implemented for `()`
-note: required by `poll`
- --> $SRC_DIR/core/src/future/future.rs:LL:COL
- |
-LL | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
LL | fake_spawn(wrong_mutex());
| ^^^^^^^^^^^^^ future returned by `wrong_mutex` is not `Send`
|
- = help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, i32>`
+ = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, i32>`
note: future is not `Send` as this value is used across an await
--> $DIR/issue-71137.rs:14:5
|
LL | let _ = foo(|x| bar(x));
| -- ^^^^^^ returning this value requires that `'1` must outlive `'2`
| ||
- | |return type of closure `impl Future` contains a lifetime `'2`
+ | |return type of closure `impl Future<Output = ()>` contains a lifetime `'2`
| has type `&'1 u8`
error: aborting due to previous error
--> $DIR/issue-84841.rs:9:5
|
LL | test()?;
- | ^^^^^^^ the `?` operator cannot be applied to type `impl Future`
+ | ^^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = ()>`
|
- = help: the trait `Try` is not implemented for `impl Future`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: the trait `Try` is not implemented for `impl Future<Output = ()>`
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/issue-84841.rs:9:11
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<_>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
| ^^^^^^^^^^^^^^^^ `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]` is not a future
|
= help: the trait `Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:12:5: 12:15]`
-note: required by `poll`
- --> $SRC_DIR/core/src/future/future.rs:LL:COL
- |
-LL | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
LL | g(issue_67893::run())
| ^^^^^^^^^^^^^^^^^^ generator is not `Send`
|
- = help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
+ = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
note: required by a bound in `g`
--> $DIR/issue-67893.rs:6:14
|
|
LL | struct Sleep(std::marker::PhantomPinned);
| ^^^^^
-note: required by `Pin::<P>::new`
+note: required by a bound in `Pin::<P>::new`
--> $SRC_DIR/core/src/pin.rs:LL:COL
|
-LL | pub const fn new(pointer: P) -> Pin<P> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<P: Deref<Target: Unpin>> Pin<P> {
+ | ^^^^^ required by this bound in `Pin::<P>::new`
error: aborting due to previous error
LL | async fn make_u32() -> u32 {
| ^^^ checked the `Output` of this `async fn`, found opaque type
= note: expected type `u32`
- found opaque type `impl Future`
+ found opaque type `impl Future<Output = u32>`
help: consider `await`ing on the `Future`
|
LL | take_u32(x.await)
};
}
+async fn dummy_result() -> Result<(), ()> {
+ Ok(())
+}
+
+#[allow(unused)]
+async fn suggest_await_in_generic_pattern() {
+ match dummy_result() {
+ //~^ HELP consider `await`ing on the `Future`
+ //~| HELP consider `await`ing on the `Future`
+ //~| SUGGESTION .await
+ Ok(_) => {}
+ //~^ ERROR mismatched types [E0308]
+ Err(_) => {}
+ //~^ ERROR mismatched types [E0308]
+ }
+}
+
fn main() {}
LL | async fn make_u32() -> u32 {
| ^^^ checked the `Output` of this `async fn`, found opaque type
= note: expected type `u32`
- found opaque type `impl Future`
+ found opaque type `impl Future<Output = u32>`
help: consider `await`ing on the `Future`
|
LL | take_u32(x.await)
LL | async fn dummy() {}
| ^ checked the `Output` of this `async fn`, found opaque type
= note: expected unit type `()`
- found opaque type `impl Future`
+ found opaque type `impl Future<Output = ()>`
help: consider `await`ing on the `Future`
|
LL | dummy().await
LL | | };
| |_____- `if` and `else` have incompatible types
|
- = note: expected type `impl Future`
+ = note: expected type `impl Future<Output = ()>`
found unit type `()`
help: consider `await`ing on the `Future`
|
LL | let _x = match 0usize {
| ______________-
LL | | 0 => dummy(),
- | | ------- this is found to be of type `impl Future`
+ | | ------- this is found to be of type `impl Future<Output = ()>`
LL | | 1 => dummy(),
- | | ------- this is found to be of type `impl Future`
+ | | ------- this is found to be of type `impl Future<Output = ()>`
LL | | 2 => dummy().await,
| | ^^^^^^^^^^^^^ expected opaque type, found `()`
LL | |
|
LL | async fn dummy() {}
| ^ checked the `Output` of this `async fn`, expected opaque type
- = note: expected opaque type `impl Future`
+ = note: expected opaque type `impl Future<Output = ()>`
found unit type `()`
help: consider `await`ing on the `Future`
|
|
LL | async fn dummy() {}
| ^ checked the `Output` of this `async fn`, expected opaque type
- = note: expected opaque type `impl Future`
+ = note: expected opaque type `impl Future<Output = ()>`
found unit type `()`
help: consider `await`ing on the `Future`
|
LL | let _x = match dummy().await {
| ++++++
-error: aborting due to 5 previous errors
+error[E0308]: mismatched types
+ --> $DIR/suggest-missing-await.rs:67:9
+ |
+LL | Ok(_) => {}
+ | ^^^^^ expected opaque type, found enum `Result`
+ |
+note: while checking the return type of the `async fn`
+ --> $DIR/suggest-missing-await.rs:57:28
+ |
+LL | async fn dummy_result() -> Result<(), ()> {
+ | ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type
+ = note: expected opaque type `impl Future<Output = Result<(), ()>>`
+ found enum `Result<_, _>`
+help: consider `await`ing on the `Future`
+ |
+LL | match dummy_result().await {
+ | ++++++
+
+error[E0308]: mismatched types
+ --> $DIR/suggest-missing-await.rs:69:9
+ |
+LL | Err(_) => {}
+ | ^^^^^^ expected opaque type, found enum `Result`
+ |
+note: while checking the return type of the `async fn`
+ --> $DIR/suggest-missing-await.rs:57:28
+ |
+LL | async fn dummy_result() -> Result<(), ()> {
+ | ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type
+ = note: expected opaque type `impl Future<Output = Result<(), ()>>`
+ found enum `Result<_, _>`
+help: consider `await`ing on the `Future`
+ |
+LL | match dummy_result().await {
+ | ++++++
+
+error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0308`.
| |_____- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-in-async.rs:17:10
| |_____- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-in-async.rs:26:6
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 3 previous errors
+++ /dev/null
-// run-pass
-
-#![allow(unused_must_use)]
-#![allow(deprecated)]
-// ignore-emscripten no threads support
-// ignore-sgx no processes
-
-use std::{env, fmt, process, sync, thread};
-
-struct SlowFmt(u32);
-impl fmt::Debug for SlowFmt {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- thread::sleep_ms(3);
- self.0.fmt(f)
- }
-}
-
-fn do_print(x: u32) {
- let x = SlowFmt(x);
- println!("{:?}{:?}{:?}{:?}{:?}", x, x, x, x, x);
-}
-
-fn main(){
- if env::args().count() == 2 {
- let barrier = sync::Arc::new(sync::Barrier::new(2));
- let tbarrier = barrier.clone();
- let t = thread::spawn(move || {
- tbarrier.wait();
- do_print(1);
- });
- barrier.wait();
- do_print(2);
- t.join();
- } else {
- let this = env::args().next().unwrap();
- let output = process::Command::new(this).arg("-").output().unwrap();
- for line in String::from_utf8(output.stdout).unwrap().lines() {
- match line.chars().next().unwrap() {
- '1' => assert_eq!(line, "11111"),
- '2' => assert_eq!(line, "22222"),
- chr => panic!("unexpected character {:?}", chr)
- }
- }
- }
-}
+++ /dev/null
-fn foo<#[attr]>() {} //~ ERROR attribute without generic parameters
-
-fn main() {}
+++ /dev/null
-error: attribute without generic parameters
- --> $DIR/attribute-with-no-generics-in-parameter-list.rs:1:8
- |
-LL | fn foo<#[attr]>() {}
- | ^^^^^^^ attributes are only permitted when preceding parameters
-
-error: aborting due to previous error
-
= note: this error originates in the macro `bug` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unexpected token: `{
- let res =
- ::alloc::fmt::format(::core::fmt::Arguments::new_v1(&[""],
- &match (&"u8",) {
- _args =>
- [::core::fmt::ArgumentV1::new(_args.0,
- ::core::fmt::Display::fmt)],
- }));
- res
-}.as_str()`
+ let res =
+ ::alloc::fmt::format(::core::fmt::Arguments::new_v1(&[""],
+ &match (&"u8",) {
+ _args =>
+ [::core::fmt::ArgumentV1::new(_args.0,
+ ::core::fmt::Display::fmt)],
+ }));
+ res
+ }.as_str()`
--> $DIR/key-value-expansion.rs:48:23
|
LL | doc_comment! {format!("{coor}", coor = stringify!($t1)).as_str()}
--- /dev/null
+#![feature(rustc_attrs)]
+
+#[rustc_dummy = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
+#[rustc_dummy = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
+fn main() {}
--- /dev/null
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:3:17
+ |
+LL | #[rustc_dummy = 1usize]
+ | ^^^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:4:17
+ |
+LL | #[rustc_dummy = 1u8]
+ | ^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:5:17
+ |
+LL | #[rustc_dummy = 1u16]
+ | ^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:6:17
+ |
+LL | #[rustc_dummy = 1u32]
+ | ^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:7:17
+ |
+LL | #[rustc_dummy = 1u64]
+ | ^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:8:17
+ |
+LL | #[rustc_dummy = 1isize]
+ | ^^^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:9:17
+ |
+LL | #[rustc_dummy = 1i8]
+ | ^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:10:17
+ |
+LL | #[rustc_dummy = 1i16]
+ | ^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:11:17
+ |
+LL | #[rustc_dummy = 1i32]
+ | ^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:12:17
+ |
+LL | #[rustc_dummy = 1i64]
+ | ^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:13:17
+ |
+LL | #[rustc_dummy = 1.0f32]
+ | ^^^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: suffixed literals are not allowed in attributes
+ --> $DIR/suffixed-literal-meta.rs:14:17
+ |
+LL | #[rustc_dummy = 1.0f64]
+ | ^^^^^^
+ |
+ = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
+
+error: aborting due to 12 previous errors
+
+++ /dev/null
-#![crate_type="lib"]
-
-pub const X: () = ();
+++ /dev/null
-#![crate_type="lib"]
-
-pub const Y: () = ();
+++ /dev/null
-extern "C" {
- pub static XA: u8;
- pub static mut XB: u8;
-}
+++ /dev/null
-#![crate_type = "lib"]
-
-pub struct Fish {
- pub x: isize
-}
-
-mod unexported {
- use super::Fish;
- impl PartialEq for Fish {
- fn eq(&self, _: &Fish) -> bool { true }
- fn ne(&self, _: &Fish) -> bool { false }
- }
-}
+++ /dev/null
-#![feature(link_cfg)]
-
-#[link(name = "foo", cfg(foo))]
-extern "C" {}
+++ /dev/null
-// no-prefer-dynamic
-
-#![feature(link_cfg)]
-#![crate_type = "rlib"]
-
-#[link(name = "foo", cfg(foo))]
-extern "C" {}
+++ /dev/null
-pub fn pr32379(mut data: u64, f1: bool, f2: bool) -> u64 {
- if f1 { data &= !2; }
- if f2 { data |= 2; }
- data
-}
+++ /dev/null
-#![crate_type = "lib"]
-
-struct Bar;
-
-impl Bar {
- #[no_mangle]
- fn bar() -> u8 {
- 2
- }
-}
-
-trait Foo {
- fn baz() -> u8;
-}
-
-impl Foo for Bar {
- #[no_mangle]
- fn baz() -> u8 {
- 3
- }
-}
+++ /dev/null
-use inner_private_module::*;
-
-mod inner_private_module {
- pub struct Unnameable1;
- pub struct Unnameable2;
- #[derive(Clone, Copy)]
- pub struct Unnameable3;
- pub struct Unnameable4;
- pub struct Unnameable5;
- pub struct Unnameable6;
- pub struct Unnameable7;
- #[derive(Default)]
- pub struct Unnameable8;
- pub enum UnnameableEnum {
- NameableVariant
- }
- pub trait UnnameableTrait {
- type Alias: Default;
- }
-
- impl Unnameable1 {
- pub fn method_of_unnameable_type1(&self) -> &'static str {
- "Hello1"
- }
- }
- impl Unnameable2 {
- pub fn method_of_unnameable_type2(&self) -> &'static str {
- "Hello2"
- }
- }
- impl Unnameable3 {
- pub fn method_of_unnameable_type3(&self) -> &'static str {
- "Hello3"
- }
- }
- impl Unnameable4 {
- pub fn method_of_unnameable_type4(&self) -> &'static str {
- "Hello4"
- }
- }
- impl Unnameable5 {
- pub fn method_of_unnameable_type5(&self) -> &'static str {
- "Hello5"
- }
- }
- impl Unnameable6 {
- pub fn method_of_unnameable_type6(&self) -> &'static str {
- "Hello6"
- }
- }
- impl Unnameable7 {
- pub fn method_of_unnameable_type7(&self) -> &'static str {
- "Hello7"
- }
- }
- impl Unnameable8 {
- pub fn method_of_unnameable_type8(&self) -> &'static str {
- "Hello8"
- }
- }
- impl UnnameableEnum {
- pub fn method_of_unnameable_enum(&self) -> &'static str {
- "HelloEnum"
- }
- }
-}
-
-pub fn function_returning_unnameable_type() -> Unnameable1 {
- Unnameable1
-}
-
-pub const CONSTANT_OF_UNNAMEABLE_TYPE: Unnameable2 =
- Unnameable2;
-
-pub fn function_accepting_unnameable_type(_: Option<Unnameable3>) {}
-
-pub type AliasOfUnnameableType = Unnameable4;
-
-impl Unnameable1 {
- pub fn inherent_method_returning_unnameable_type(&self) -> Unnameable5 {
- Unnameable5
- }
-}
-
-pub trait Tr {
- fn trait_method_returning_unnameable_type(&self) -> Unnameable6 {
- Unnameable6
- }
-}
-impl Tr for Unnameable1 {}
-
-pub use inner_private_module::UnnameableEnum::NameableVariant;
-
-pub struct Struct {
- pub field_of_unnameable_type: Unnameable7
-}
-
-pub static STATIC: Struct = Struct { field_of_unnameable_type: Unnameable7 } ;
-
-impl UnnameableTrait for AliasOfUnnameableType {
- type Alias = Unnameable8;
-}
-
-pub fn generic_function<T: UnnameableTrait>() -> T::Alias {
- Default::default()
-}
+++ /dev/null
-// run-pass
-// ignore-test: not a test, used by backtrace-debuginfo.rs to test file!()
-
-#[inline(never)]
-pub fn callback<F>(f: F) where F: FnOnce((&'static str, u32)) {
- f((file!(), line!()))
-}
-
-// We emit the wrong location for the caller here when inlined on MSVC
-#[cfg_attr(not(target_env = "msvc"), inline(always))]
-#[cfg_attr(target_env = "msvc", inline(never))]
-pub fn callback_inlined<F>(f: F) where F: FnOnce((&'static str, u32)) {
- f((file!(), line!()))
-}
+++ /dev/null
-// run-pass
-// We disable tail merging here because it can't preserve debuginfo and thus
-// potentially breaks the backtraces. Also, subtle changes can decide whether
-// tail merging succeeds, so the test might work today but fail tomorrow due to a
-// seemingly completely unrelated change.
-// Unfortunately, LLVM has no "disable" option for this, so we have to set
-// "enable" to 0 instead.
-
-// compile-flags:-g -Copt-level=0 -Cllvm-args=-enable-tail-merge=0
-// compile-flags:-Cforce-frame-pointers=yes
-// ignore-pretty issue #37195
-// ignore-emscripten spawning processes is not supported
-// ignore-sgx no processes
-
-use std::env;
-
-#[path = "backtrace-debuginfo-aux.rs"] mod aux;
-
-macro_rules! pos {
- () => ((file!(), line!()))
-}
-
-macro_rules! dump_and_die {
- ($($pos:expr),*) => ({
- // FIXME(#18285): we cannot include the current position because
- // the macro span takes over the last frame's file/line.
- //
- // You might also be wondering why a major platform,
- // i686-pc-windows-msvc, is located in here. Some of the saga can be
- // found on #62897, but the tl;dr; is that it appears that if the
- // standard library doesn't have debug information or frame pointers,
- // which it doesn't by default on the test builders, then the stack
- // walking routines in dbghelp will randomly terminate the stack trace
- // in libstd without going further. Presumably the addition of frame
- // pointers and/or debuginfo fixes this since tests always work with
- // nightly compilers (which have debuginfo). In general though this test
- // is replicated in rust-lang/backtrace-rs and has extensive coverage
- // there, even on i686-pc-windows-msvc. We do the best we can in
- // rust-lang/rust to test it as well, but sometimes we just gotta keep
- // landing PRs.
- if cfg!(any(target_os = "android",
- all(target_os = "linux", target_arch = "arm"),
- all(target_env = "msvc", target_arch = "x86"),
- target_os = "freebsd",
- target_os = "dragonfly",
- target_os = "openbsd")) {
- // skip these platforms as this support isn't implemented yet.
- } else {
- dump_filelines(&[$($pos),*]);
- panic!();
- }
- })
-}
-
-// we can't use a function as it will alter the backtrace
-macro_rules! check {
- ($counter:expr; $($pos:expr),*) => ({
- if *$counter == 0 {
- dump_and_die!($($pos),*)
- } else {
- *$counter -= 1;
- }
- })
-}
-
-type Pos = (&'static str, u32);
-
-// this goes to stdout and each line has to be occurred
-// in the following backtrace to stderr with a correct order.
-fn dump_filelines(filelines: &[Pos]) {
- for &(file, line) in filelines.iter().rev() {
- // extract a basename
- let basename = file.split(&['/', '\\'][..]).last().unwrap();
- println!("{}:{}", basename, line);
- }
-}
-
-#[inline(never)]
-fn inner(counter: &mut i32, main_pos: Pos, outer_pos: Pos) {
- check!(counter; main_pos, outer_pos);
- check!(counter; main_pos, outer_pos);
- let inner_pos = pos!(); aux::callback(|aux_pos| {
- check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
- });
- let inner_pos = pos!(); aux::callback_inlined(|aux_pos| {
- check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
- });
-}
-
-// We emit the wrong location for the caller here when inlined on MSVC
-#[cfg_attr(not(target_env = "msvc"), inline(always))]
-#[cfg_attr(target_env = "msvc", inline(never))]
-fn inner_inlined(counter: &mut i32, main_pos: Pos, outer_pos: Pos) {
- check!(counter; main_pos, outer_pos);
- check!(counter; main_pos, outer_pos);
-
- // Again, disable inlining for MSVC.
- #[cfg_attr(not(target_env = "msvc"), inline(always))]
- #[cfg_attr(target_env = "msvc", inline(never))]
- fn inner_further_inlined(counter: &mut i32, main_pos: Pos, outer_pos: Pos, inner_pos: Pos) {
- check!(counter; main_pos, outer_pos, inner_pos);
- }
- inner_further_inlined(counter, main_pos, outer_pos, pos!());
-
- let inner_pos = pos!(); aux::callback(|aux_pos| {
- check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
- });
- let inner_pos = pos!(); aux::callback_inlined(|aux_pos| {
- check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
- });
-
- // this tests a distinction between two independent calls to the inlined function.
- // (un)fortunately, LLVM somehow merges two consecutive such calls into one node.
- inner_further_inlined(counter, main_pos, outer_pos, pos!());
-}
-
-#[inline(never)]
-fn outer(mut counter: i32, main_pos: Pos) {
- inner(&mut counter, main_pos, pos!());
- inner_inlined(&mut counter, main_pos, pos!());
-}
-
-fn check_trace(output: &str, error: &str) -> Result<(), String> {
- // reverse the position list so we can start with the last item (which was the first line)
- let mut remaining: Vec<&str> = output.lines().map(|s| s.trim()).rev().collect();
-
- if !error.contains("stack backtrace") {
- return Err(format!("no backtrace found in stderr:\n{}", error))
- }
- for line in error.lines() {
- if !remaining.is_empty() && line.contains(remaining.last().unwrap()) {
- remaining.pop();
- }
- }
- if !remaining.is_empty() {
- return Err(format!("trace does not match position list\n\
- still need to find {:?}\n\n\
- --- stdout\n{}\n\
- --- stderr\n{}",
- remaining, output, error))
- }
- Ok(())
-}
-
-fn run_test(me: &str) {
- use std::str;
- use std::process::Command;
-
- let mut i = 0;
- let mut errors = Vec::new();
- loop {
- let out = Command::new(me)
- .env("RUST_BACKTRACE", "full")
- .arg(i.to_string()).output().unwrap();
- let output = str::from_utf8(&out.stdout).unwrap();
- let error = str::from_utf8(&out.stderr).unwrap();
- if out.status.success() {
- assert!(output.contains("done."), "bad output for successful run: {}", output);
- break;
- } else {
- if let Err(e) = check_trace(output, error) {
- errors.push(e);
- }
- }
- i += 1;
- }
- if errors.len() > 0 {
- for error in errors {
- println!("---------------------------------------");
- println!("{}", error);
- }
-
- panic!("found some errors");
- }
-}
-
-#[inline(never)]
-fn main() {
- let args: Vec<String> = env::args().collect();
- if args.len() >= 2 {
- let case = args[1].parse().unwrap();
- eprintln!("test case {}", case);
- outer(case, pos!());
- println!("done.");
- } else {
- run_test(&args[0]);
- }
-}
--- /dev/null
+// run-pass
+// Test that we can overload the `+` operator for points so that two
+// points can be added, and a point can be added to an integer.
+
+use std::ops;
+
+#[derive(Debug,PartialEq,Eq)]
+struct Point {
+ x: isize,
+ y: isize
+}
+
+impl ops::Add for Point {
+ type Output = Point;
+
+ fn add(self, other: Point) -> Point {
+ Point {x: self.x + other.x, y: self.y + other.y}
+ }
+}
+
+impl ops::Add<isize> for Point {
+ type Output = Point;
+
+ fn add(self, other: isize) -> Point {
+ Point {x: self.x + other,
+ y: self.y + other}
+ }
+}
+
+pub fn main() {
+ let mut p = Point {x: 10, y: 20};
+ p = p + Point {x: 101, y: 102};
+ assert_eq!(p, Point {x: 111, y: 122});
+ p = p + 1;
+ assert_eq!(p, Point {x: 112, y: 123});
+}
--- /dev/null
+// run-pass
+
+#![allow(unused_variables)]
+use std::cmp;
+use std::ops;
+
+#[derive(Copy, Clone, Debug)]
+struct Point {
+ x: isize,
+ y: isize
+}
+
+impl ops::Add for Point {
+ type Output = Point;
+
+ fn add(self, other: Point) -> Point {
+ Point {x: self.x + other.x, y: self.y + other.y}
+ }
+}
+
+impl ops::Sub for Point {
+ type Output = Point;
+
+ fn sub(self, other: Point) -> Point {
+ Point {x: self.x - other.x, y: self.y - other.y}
+ }
+}
+
+impl ops::Neg for Point {
+ type Output = Point;
+
+ fn neg(self) -> Point {
+ Point {x: -self.x, y: -self.y}
+ }
+}
+
+impl ops::Not for Point {
+ type Output = Point;
+
+ fn not(self) -> Point {
+ Point {x: !self.x, y: !self.y }
+ }
+}
+
+impl ops::Index<bool> for Point {
+ type Output = isize;
+
+ fn index(&self, x: bool) -> &isize {
+ if x {
+ &self.x
+ } else {
+ &self.y
+ }
+ }
+}
+
+impl cmp::PartialEq for Point {
+ fn eq(&self, other: &Point) -> bool {
+ (*self).x == (*other).x && (*self).y == (*other).y
+ }
+ fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
+}
+
+pub fn main() {
+ let mut p = Point {x: 10, y: 20};
+ p = p + Point {x: 101, y: 102};
+ p = p - Point {x: 100, y: 100};
+ assert_eq!(p + Point {x: 5, y: 5}, Point {x: 16, y: 27});
+ assert_eq!(-p, Point {x: -11, y: -22});
+ assert_eq!(p[true], 11);
+ assert_eq!(p[false], 22);
+
+ let q = !p;
+ assert_eq!(q.x, !(p.x));
+ assert_eq!(q.y, !(p.y));
+
+ // Issue #1733
+ result(p[true]);
+}
+
+fn result(i: isize) { }
--- /dev/null
+fn main() {
+ let x = -5;
+ if x<-1 { //~ ERROR unexpected token: `<-`
+ println!("ok");
+ }
+}
--- /dev/null
+error: unexpected token: `<-`
+ --> $DIR/placement-syntax.rs:3:9
+ |
+LL | if x<-1 {
+ | ^^
+ |
+help: if you meant to write a comparison against a negative value, add a space in between `<` and `-`
+ |
+LL | if x< -1 {
+ | ~~~
+
+error: aborting due to previous error
+
+++ /dev/null
-// run-pass
-// aux-build:blind-item-mixed-crate-use-item-foo.rs
-// aux-build:blind-item-mixed-crate-use-item-foo2.rs
-
-// pretty-expanded FIXME #23616
-
-mod m {
- pub fn f<T>(_: T, _: (), _: ()) { }
- pub fn g<T>(_: T, _: (), _: ()) { }
-}
-
-const BAR: () = ();
-struct Data;
-use m::f;
-extern crate blind_item_mixed_crate_use_item_foo as foo;
-
-fn main() {
- const BAR2: () = ();
- struct Data2;
- use m::g;
-
- extern crate blind_item_mixed_crate_use_item_foo2 as foo2;
-
- f(Data, BAR, foo::X);
- g(Data2, BAR2, foo2::Y);
-}
+++ /dev/null
-// run-pass
-// pretty-expanded FIXME #23616
-
-mod m {
- pub fn f<T>(_: T, _: ()) { }
- pub fn g<T>(_: T, _: ()) { }
-}
-
-const BAR: () = ();
-struct Data;
-use m::f;
-
-fn main() {
- const BAR2: () = ();
- struct Data2;
- use m::g;
-
- f(Data, BAR);
- g(Data2, BAR2);
-}
--- /dev/null
+fn f(y: Box<isize>) {
+ *y = 5; //~ ERROR cannot assign
+}
+
+fn g() {
+ let _frob = |q: Box<isize>| { *q = 2; }; //~ ERROR cannot assign
+}
+
+fn main() {}
--- /dev/null
+error[E0594]: cannot assign to `*y`, as `y` is not declared as mutable
+ --> $DIR/immut-function-arguments.rs:2:5
+ |
+LL | fn f(y: Box<isize>) {
+ | - help: consider changing this to be mutable: `mut y`
+LL | *y = 5;
+ | ^^^^^^ cannot assign
+
+error[E0594]: cannot assign to `*q`, as `q` is not declared as mutable
+ --> $DIR/immut-function-arguments.rs:6:35
+ |
+LL | let _frob = |q: Box<isize>| { *q = 2; };
+ | - ^^^^^^ cannot assign
+ | |
+ | help: consider changing this to be mutable: `mut q`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0594`.
--- /dev/null
+// run-pass
+
+#![allow(unused_must_use)]
+#![allow(dead_code)]
+use std::thread;
+
+fn user(_i: isize) {}
+
+fn foo() {
+ // Here, i is *copied* into the proc (heap closure).
+ // Requires allocation. The proc's copy is not mutable.
+ let mut i = 0;
+ let t = thread::spawn(move|| {
+ user(i);
+ println!("spawned {}", i)
+ });
+ i += 1;
+ println!("original {}", i);
+ t.join();
+}
+
+fn bar() {
+ // Here, the original i has not been moved, only copied, so is still
+ // mutable outside of the proc.
+ let mut i = 0;
+ while i < 10 {
+ let t = thread::spawn(move|| {
+ user(i);
+ });
+ i += 1;
+ t.join();
+ }
+}
+
+fn car() {
+ // Here, i must be shadowed in the proc to be mutable.
+ let mut i = 0;
+ while i < 10 {
+ let t = thread::spawn(move|| {
+ let mut i = i;
+ i += 1;
+ user(i);
+ });
+ i += 1;
+ t.join();
+ }
+}
+
+pub fn main() {}
| ^ lifetimes do not match method in trait
error[E0276]: impl has stricter requirements than trait
- --> $DIR/regions-bound-missing-bound-in-impl.rs:49:5
+ --> $DIR/regions-bound-missing-bound-in-impl.rs:49:26
|
LL | fn another_bound<'x: 'a>(self, x: Inv<'x>, y: Inv<'t>);
| ------------------------------------------------------- definition of `another_bound` from trait
...
LL | fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'x: 't`
+ | ^^ impl has extra requirement `'x: 't`
error: aborting due to 6 previous errors
let key = f(x);
result.entry(key).or_insert(Vec::new()).push(x);
}
- result //~ ERROR cannot return value referencing local binding
+ result //~ ERROR cannot return value referencing temporary value
}
fn main() {}
-error[E0515]: cannot return value referencing local binding
+error[E0515]: cannot return value referencing temporary value
--> $DIR/return-local-binding-from-desugaring.rs:30:5
|
LL | for ref x in xs {
- | -- local binding introduced here
+ | -- temporary value created here
...
LL | result
| ^^^^^^ returns a value referencing data owned by the current function
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `[u8]`
-note: required by `Box::<T, A>::into_boxed_slice`
+note: required by a bound in `Box::<T, A>::into_boxed_slice`
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
-LL | pub fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<T, A: Allocator> Box<T, A> {
+ | ^ required by this bound in `Box::<T, A>::into_boxed_slice`
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/into-boxed-slice-fail.rs:7:13
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `dyn Debug`
-note: required by `Box::<T, A>::into_boxed_slice`
+note: required by a bound in `Box::<T, A>::into_boxed_slice`
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
-LL | pub fn into_boxed_slice(boxed: Self) -> Box<[T], A> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<T, A: Allocator> Box<T, A> {
+ | ^ required by this bound in `Box::<T, A>::into_boxed_slice`
error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
--> $DIR/into-boxed-slice-fail.rs:11:13
+++ /dev/null
-struct Foo {
- t: String
-}
-
-fn cond() -> bool { true }
-
-fn foo<F>(_: F) where F: FnOnce() {}
-
-fn main() {
- let pth = break; //~ ERROR: `break` outside of a loop
- if cond() { continue } //~ ERROR: `continue` outside of a loop
-
- while cond() {
- if cond() { break }
- if cond() { continue }
- foo(|| {
- if cond() { break } //~ ERROR: `break` inside of a closure
- if cond() { continue } //~ ERROR: `continue` inside of a closure
- })
- }
-
- let rs: Foo = Foo{t: pth};
-
- let unconstrained = break; //~ ERROR: `break` outside of a loop
-
- // This used to ICE because `target_id` passed to `check_expr_break` would be the closure and
- // not the `loop`, which failed in the call to `find_breakable`. (#65383)
- 'lab: loop {
- || {
- break 'lab;
- //~^ ERROR use of unreachable label `'lab`
- //~| ERROR `break` inside of a closure
- };
- }
-}
+++ /dev/null
-error[E0767]: use of unreachable label `'lab`
- --> $DIR/break-outside-loop.rs:30:19
- |
-LL | 'lab: loop {
- | ---- unreachable label defined here
-LL | || {
-LL | break 'lab;
- | ^^^^ unreachable label `'lab`
- |
- = note: labels are unreachable through functions, closures, async blocks and modules
-
-error[E0268]: `break` outside of a loop
- --> $DIR/break-outside-loop.rs:10:15
- |
-LL | let pth = break;
- | ^^^^^ cannot `break` outside of a loop
-
-error[E0268]: `continue` outside of a loop
- --> $DIR/break-outside-loop.rs:11:17
- |
-LL | if cond() { continue }
- | ^^^^^^^^ cannot `continue` outside of a loop
-
-error[E0267]: `break` inside of a closure
- --> $DIR/break-outside-loop.rs:17:25
- |
-LL | foo(|| {
- | -- enclosing closure
-LL | if cond() { break }
- | ^^^^^ cannot `break` inside of a closure
-
-error[E0267]: `continue` inside of a closure
- --> $DIR/break-outside-loop.rs:18:25
- |
-LL | foo(|| {
- | -- enclosing closure
-LL | if cond() { break }
-LL | if cond() { continue }
- | ^^^^^^^^ cannot `continue` inside of a closure
-
-error[E0268]: `break` outside of a loop
- --> $DIR/break-outside-loop.rs:24:25
- |
-LL | let unconstrained = break;
- | ^^^^^ cannot `break` outside of a loop
-
-error[E0267]: `break` inside of a closure
- --> $DIR/break-outside-loop.rs:30:13
- |
-LL | || {
- | -- enclosing closure
-LL | break 'lab;
- | ^^^^^^^^^^ cannot `break` inside of a closure
-
-error: aborting due to 7 previous errors
-
-Some errors have detailed explanations: E0267, E0268, E0767.
-For more information about an error, try `rustc --explain E0267`.
+++ /dev/null
-#![feature(never_type)]
-
-fn main() {
- // The `if false` expressions are simply to
- // make sure we don't avoid checking everything
- // simply because a few expressions are unreachable.
-
- if false {
- let _: ! = { //~ ERROR mismatched types
- 'a: while break 'a {};
- };
- }
-
- if false {
- let _: ! = {
- while false { //~ ERROR mismatched types
- break
- }
- };
- }
-
- if false {
- let _: ! = {
- while false { //~ ERROR mismatched types
- return
- }
- };
- }
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/break-while-condition.rs:9:20
- |
-LL | let _: ! = {
- | ____________________^
-LL | | 'a: while break 'a {};
-LL | | };
- | |_________^ expected `!`, found `()`
- |
- = note: expected type `!`
- found unit type `()`
-
-error[E0308]: mismatched types
- --> $DIR/break-while-condition.rs:16:13
- |
-LL | / while false {
-LL | | break
-LL | | }
- | |_____________^ expected `!`, found `()`
- |
- = note: expected type `!`
- found unit type `()`
-
-error[E0308]: mismatched types
- --> $DIR/break-while-condition.rs:24:13
- |
-LL | / while false {
-LL | | return
-LL | | }
- | |_____________^ expected `!`, found `()`
- |
- = note: expected type `!`
- found unit type `()`
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// run-pass
-//
-
-
-static FOO: u8 = b'\xF0';
-static BAR: &'static [u8] = b"a\xF0\t";
-static BAR_FIXED: &'static [u8; 3] = b"a\xF0\t";
-static BAZ: &'static [u8] = br"a\n";
-
-pub fn main() {
- let bar: &'static [u8] = b"a\xF0\t";
- let bar_fixed: &'static [u8; 3] = b"a\xF0\t";
-
- assert_eq!(b'a', 97u8);
- assert_eq!(b'\n', 10u8);
- assert_eq!(b'\r', 13u8);
- assert_eq!(b'\t', 9u8);
- assert_eq!(b'\\', 92u8);
- assert_eq!(b'\'', 39u8);
- assert_eq!(b'\"', 34u8);
- assert_eq!(b'\0', 0u8);
- assert_eq!(b'\xF0', 240u8);
- assert_eq!(FOO, 240u8);
-
- match 42 {
- b'*' => {},
- _ => panic!()
- }
-
- match 100 {
- b'a' ..= b'z' => {},
- _ => panic!()
- }
-
- let expected: &[_] = &[97u8, 10u8, 13u8, 9u8, 92u8, 39u8, 34u8, 0u8, 240u8];
- assert_eq!(b"a\n\r\t\\\'\"\0\xF0", expected);
- let expected: &[_] = &[97u8, 98u8];
- assert_eq!(b"a\
- b", expected);
- let expected: &[_] = &[97u8, 240u8, 9u8];
- assert_eq!(BAR, expected);
- assert_eq!(BAR_FIXED, expected);
- assert_eq!(bar, expected);
- assert_eq!(bar_fixed, expected);
-
- let val = &[97u8, 10u8];
- match val {
- b"a\n" => {},
- _ => panic!(),
- }
-
- let buf = vec![97u8, 98, 99, 100];
- assert_eq!(match &buf[0..3] {
- b"def" => 1,
- b"abc" => 2,
- _ => 3
- }, 2);
-
- let expected: &[_] = &[97u8, 92u8, 110u8];
- assert_eq!(BAZ, expected);
- let expected: &[_] = &[97u8, 92u8, 110u8];
- assert_eq!(br"a\n", expected);
- assert_eq!(br"a\n", b"a\\n");
- let expected: &[_] = &[97u8, 34u8, 35u8, 35u8, 98u8];
- assert_eq!(br###"a"##b"###, expected);
- assert_eq!(br###"a"##b"###, b"a\"##b");
-}
-error[E0606]: casting `*mut impl Debug+?Sized` as `*mut impl Debug+?Sized` is invalid
+error[E0606]: casting `*mut impl Debug + ?Sized` as `*mut impl Debug + ?Sized` is invalid
--> $DIR/casts-differing-anon.rs:21:13
|
LL | b_raw = f_raw as *mut _;
--- /dev/null
+// run-pass
+// compile-flags:-C target-feature=+crt-static
+// only-msvc
+
+#[cfg(target_feature = "crt-static")]
+fn main() {}
= help: the following implementations were found:
<Option<T> as Foo>
<i32 as Foo>
-note: required by `S`
- --> $DIR/type_wf.rs:6:1
+note: required by a bound in `S`
+ --> $DIR/type_wf.rs:6:13
|
LL | struct S<T: Foo> {
- | ^^^^^^^^^^^^^^^^
+ | ^^^ required by this bound in `S`
error: aborting due to previous error
+++ /dev/null
-// run-pass
-
-#![allow(stable_features)]
-#![allow(unused_imports)]
-// Test that cleanup scope for temporaries created in a match
-// arm is confined to the match arm itself.
-
-// pretty-expanded FIXME #23616
-
-#![feature(os)]
-
-use std::os;
-
-struct Test { x: isize }
-
-impl Test {
- fn get_x(&self) -> Option<Box<isize>> {
- Some(Box::new(self.x))
- }
-}
-
-fn do_something(t: &Test) -> isize {
-
- // The cleanup scope for the result of `t.get_x()` should be the
- // arm itself and not the match, otherwise we'll (potentially) get
- // a crash trying to free an uninitialized stack slot.
-
- match t {
- &Test { x: 2 } if t.get_x().is_some() => {
- t.x * 2
- }
- _ => { 22 }
- }
-}
-
-pub fn main() {
- let t = Test { x: 1 };
- do_something(&t);
-}
+++ /dev/null
-// run-pass
-
-#![allow(unused_must_use)]
-// ignore-emscripten no threads support
-
-use std::thread;
-
-struct Pair {
- a: isize,
- b: isize
-}
-
-pub fn main() {
- let z: Box<_> = Box::new(Pair { a : 10, b : 12});
-
- thread::spawn(move|| {
- assert_eq!(z.a, 10);
- assert_eq!(z.b, 12);
- }).join();
-}
|
= help: the trait `FnOnce<()>` is not implemented for `{integer}`
= note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }`
+note: required by a bound in `Option::<T>::or_else`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ |
+LL | pub fn or_else<F: FnOnce() -> Option<T>>(self, f: F) -> Option<T> {
+ | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::or_else`
error: aborting due to previous error
| required by a bound introduced by this call
|
= help: the trait `FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
+note: required by a bound in `Option::<T>::map`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ |
+LL | pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
+ | ^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
error: aborting due to previous error
--- /dev/null
+// run-pass
+// Testing guarantees provided by once functions.
+
+
+
+use std::sync::Arc;
+
+fn foo<F:FnOnce()>(blk: F) {
+ blk();
+}
+
+pub fn main() {
+ let x = Arc::new(true);
+ foo(move|| {
+ assert!(*x);
+ drop(x);
+ });
+}
error: <unknown>:0:0: in function test i32 (i32, i32, i32, i32, i32): call to non-secure function would require passing arguments on stack
-
error: aborting due to previous error
error: <unknown>:0:0: in function entry_function i32 (i32, i32, i32, i32, i32): secure entry function requires arguments on stack
-
error: aborting due to previous error
--- /dev/null
+pub fn pr32379(mut data: u64, f1: bool, f2: bool) -> u64 {
+ if f1 { data &= !2; }
+ if f2 { data |= 2; }
+ data
+}
--- /dev/null
+// compile-flags: -O
+// run-pass
+
+#![allow(unused_must_use)]
+// Makes sure that zero-initializing large types is reasonably fast,
+// Doing it incorrectly causes massive slowdown in LLVM during
+// optimisation.
+
+// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
+
+#![feature(intrinsics)]
+
+use std::{mem, thread};
+
+const SIZE: usize = 1024 * 1024;
+
+fn main() {
+ // do the test in a new thread to avoid (spurious?) stack overflows
+ thread::spawn(|| {
+ let _memory: [u8; SIZE] = unsafe { mem::zeroed() };
+ }).join();
+}
--- /dev/null
+// run-pass
+// aux-build:llvm_pr32379.rs
+
+// LLVM PR #32379 (https://bugs.llvm.org/show_bug.cgi?id=32379), which
+// applies to upstream LLVM 3.9.1, is known to cause rustc itself to be
+// miscompiled on ARM (Rust issue #40593). Because cross builds don't test
+// our *compiler* on ARM, have a test for the miscompilation directly.
+
+extern crate llvm_pr32379;
+
+pub fn main() {
+ let val = llvm_pr32379::pr32379(2, false, false);
+ assert_eq!(val, 2);
+}
--- /dev/null
+#![allow(warnings)]
+
+pub fn fail(x: Option<&(Iterator<Item=()>+Send)>)
+ -> Option<&Iterator<Item=()>> {
+ // This call used to trigger an LLVM assertion because the return
+ // slot had type "Option<&Iterator>"* instead of
+ // "Option<&(Iterator+Send)>"* -- but this now yields a
+ // compilation error and I'm not sure how to create a comparable
+ // test. To ensure that this PARTICULAR failure doesn't occur
+ // again, though, I've left this test here, so if this ever starts
+ // to compile again, we can adjust the test appropriately (clearly
+ // it should never ICE...). -nmatsakis
+ inner(x) //~ ERROR mismatched types
+}
+
+pub fn inner(x: Option<&(Iterator<Item=()>+Send)>)
+ -> Option<&(Iterator<Item=()>+Send)> {
+ x
+}
+
+
+fn main() {}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/retslot-cast.rs:13:5
+ |
+LL | -> Option<&Iterator<Item=()>> {
+ | -------------------------- expected `Option<&dyn Iterator<Item = ()>>` because of return type
+...
+LL | inner(x)
+ | ^^^^^^^^ expected trait `Iterator<Item = ()>`, found trait `Iterator<Item = ()> + Send`
+ |
+ = note: expected enum `Option<&dyn Iterator<Item = ()>>`
+ found enum `Option<&dyn Iterator<Item = ()> + Send>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
LL | #[rustc_strict_coherence]
LL | impl C for u32 {}
| ^^^^^^^^^^^^^^
-note: required by a bound in `C`
- --> $DIR/coherence-overlap-trait-alias.rs:11:1
- |
-LL | trait C {}
- | ^^^^^^^ required by this bound in `C`
error: aborting due to previous error
error[E0276]: impl has stricter requirements than trait
- --> $DIR/proj-outlives-region.rs:9:5
+ --> $DIR/proj-outlives-region.rs:9:23
|
LL | fn foo() where T: 'a;
| --------------------- definition of `foo` from trait
...
LL | fn foo() where U: 'a { }
- | ^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a`
+ | ^^ impl has extra requirement `U: 'a`
error: aborting due to previous error
error[E0276]: impl has stricter requirements than trait
- --> $DIR/region-extra-2.rs:9:5
+ --> $DIR/region-extra-2.rs:9:53
|
LL | fn renew<'b: 'a>(self) -> &'b mut [T];
| -------------------------------------- definition of `renew` from trait
...
LL | fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b`
+ | ^^ impl has extra requirement `'a: 'b`
error: aborting due to previous error
error[E0276]: impl has stricter requirements than trait
- --> $DIR/region-extra.rs:9:5
+ --> $DIR/region-extra.rs:9:24
|
LL | fn foo();
| --------- definition of `foo` from trait
...
LL | fn foo() where 'a: 'b { }
- | ^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'a: 'b`
+ | ^^ impl has extra requirement `'a: 'b`
error: aborting due to previous error
error[E0276]: impl has stricter requirements than trait
- --> $DIR/region-unrelated.rs:9:5
+ --> $DIR/region-unrelated.rs:9:23
|
LL | fn foo() where T: 'a;
| --------------------- definition of `foo` from trait
...
LL | fn foo() where V: 'a { }
- | ^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a`
+ | ^^ impl has extra requirement `V: 'a`
error: aborting due to previous error
error[E0276]: impl has stricter requirements than trait
- --> $DIR/trait-bound-on-type-parameter.rs:15:5
+ --> $DIR/trait-bound-on-type-parameter.rs:15:13
|
LL | fn b<C,D>(&self, x: C) -> C;
| ---------------------------- definition of `b` from trait
...
LL | fn b<F: Sync, G>(&self, _x: F) -> F { panic!() }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `F: Sync`
+ | ^^^^ impl has extra requirement `F: Sync`
error: aborting due to previous error
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-1.rs:27:5
+ --> $DIR/traits-misc-mismatch-1.rs:27:26
|
LL | fn test_error1_fn<T: Eq>(&self);
| -------------------------------- definition of `test_error1_fn` from trait
...
LL | fn test_error1_fn<T: Ord>(&self) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Ord`
+ | ^^^ impl has extra requirement `T: Ord`
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-1.rs:31:5
+ --> $DIR/traits-misc-mismatch-1.rs:31:31
|
LL | fn test_error2_fn<T: Eq + Ord>(&self);
| -------------------------------------- definition of `test_error2_fn` from trait
...
LL | fn test_error2_fn<T: Eq + B>(&self) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
+ | ^ impl has extra requirement `T: B`
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-1.rs:35:5
+ --> $DIR/traits-misc-mismatch-1.rs:35:26
|
LL | fn test_error3_fn<T: Eq + Ord>(&self);
| -------------------------------------- definition of `test_error3_fn` from trait
...
LL | fn test_error3_fn<T: B + Eq>(&self) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
+ | ^ impl has extra requirement `T: B`
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-1.rs:45:5
+ --> $DIR/traits-misc-mismatch-1.rs:45:26
|
LL | fn test_error5_fn<T: A>(&self);
| ------------------------------- definition of `test_error5_fn` from trait
...
LL | fn test_error5_fn<T: B>(&self) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
+ | ^ impl has extra requirement `T: B`
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-1.rs:51:5
+ --> $DIR/traits-misc-mismatch-1.rs:51:30
|
LL | fn test_error7_fn<T: A>(&self);
| ------------------------------- definition of `test_error7_fn` from trait
...
LL | fn test_error7_fn<T: A + Eq>(&self) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Eq`
+ | ^^ impl has extra requirement `T: Eq`
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-1.rs:54:5
+ --> $DIR/traits-misc-mismatch-1.rs:54:26
|
LL | fn test_error8_fn<T: B>(&self);
| ------------------------------- definition of `test_error8_fn` from trait
...
LL | fn test_error8_fn<T: C>(&self) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: C`
+ | ^ impl has extra requirement `T: C`
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-1.rs:67:5
+ --> $DIR/traits-misc-mismatch-1.rs:67:18
|
LL | fn method<G:Getter<isize>>(&self);
| ---------------------------------- definition of `method` from trait
...
LL | fn method<G: Getter<usize>>(&self) {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter<usize>`
+ | ^^^^^^^^^^^^^ impl has extra requirement `G: Getter<usize>`
error: aborting due to 7 previous errors
error[E0276]: impl has stricter requirements than trait
- --> $DIR/traits-misc-mismatch-2.rs:13:5
+ --> $DIR/traits-misc-mismatch-2.rs:13:18
|
LL | fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
| ------------------------------------------------------------------ definition of `zip` from trait
...
LL | fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: Iterator<B>`
+ | ^^^^^^^^^^^ impl has extra requirement `U: Iterator<B>`
error: aborting due to previous error
|
= help: the following implementations were found:
<() as Trait<3_u8>>
-note: required by `WhereClause`
- --> $DIR/wfness.rs:8:1
- |
-LL | struct WhereClause<const N: u8 = 2> where (): Trait<N>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `(): Trait<1_u8>` is not satisfied
--> $DIR/wfness.rs:16:13
|
LL | <[Adt; std::mem::size_of::<Self::Assoc>()] as Foo>::bar()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[Adt; _]`
- |
-note: required by `Foo::bar`
- --> $DIR/dont-evaluate-array-len-on-err-1.rs:19:5
- |
-LL | fn bar() {}
- | ^^^^^^^^
error: aborting due to previous error
<() as Foo<101_u8>>
<() as Foo<102_u8>>
and 252 others
-note: required by `Foo::test`
- --> $DIR/exhaustive-value.rs:2:5
- |
-LL | fn test() {}
- | ^^^^^^^^^
error: aborting due to previous error
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
-note: required by a bound in `True`
- --> $DIR/issue-72787.rs:8:1
- |
-LL | pub trait True {}
- | ^^^^^^^^^^^^^^ required by this bound in `True`
error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:21:26
| ^^^^ cannot infer type for struct `IsLessOrEqual<I, 8_u32>`
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
-note: required by a bound in `True`
- --> $DIR/issue-72787.rs:8:1
- |
-LL | pub trait True {}
- | ^^^^^^^^^^^^^^ required by this bound in `True`
error: aborting due to 6 previous errors
| ^^^^
|
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
+note: required by a bound in `TensorSize::size`
+ --> $DIR/issue-83765.rs:9:31
+ |
+LL | fn size(&self) -> [usize; Self::DIM];
+ | ^^^^^^^^^ required by this bound in `TensorSize::size`
error[E0308]: mismatched types
--> $DIR/issue-83765.rs:32:9
--- /dev/null
+warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())`
+ --> $DIR/invariant.rs:14:1
+ |
+LL | impl SadBee for for<'a> fn(&'a ()) {
+ | ---------------------------------- first implementation here
+...
+LL | impl SadBee for fn(&'static ()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a> fn(&'a ())`
+ |
+ = note: `#[warn(coherence_leak_check)]` on by default
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
+ = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
+
+error[E0308]: mismatched types
+ --> $DIR/invariant.rs:27:5
+ |
+LL | v
+ | ^ one type is more general than the other
+ |
+ = note: expected reference `&Foo<fn(&())>`
+ found reference `&Foo<for<'a> fn(&'a ())>`
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+use std::marker::PhantomData;
+
+trait SadBee {
+ const ASSOC: usize;
+}
+// fn(&'static ())` is a supertype of `for<'a> fn(&'a ())` while
+// we allow two different impls for these types, leading
+// to different const eval results.
+impl SadBee for for<'a> fn(&'a ()) {
+ const ASSOC: usize = 0;
+}
+impl SadBee for fn(&'static ()) {
+ //~^ WARNING conflicting implementations of trait
+ //~| WARNING this was previously accepted
+ const ASSOC: usize = 100;
+}
+
+struct Foo<T: SadBee>([u8; <T as SadBee>::ASSOC], PhantomData<T>)
+where
+ [(); <T as SadBee>::ASSOC]: ;
+
+fn covariant(
+ v: &'static Foo<for<'a> fn(&'a ())>
+) -> &'static Foo<fn(&'static ())> {
+ v //~ ERROR mismatched types
+}
+
+fn main() {
+ let y = covariant(&Foo([], PhantomData));
+ println!("{:?}", y.0);
+}
--- /dev/null
+warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())`
+ --> $DIR/invariant.rs:14:1
+ |
+LL | impl SadBee for for<'a> fn(&'a ()) {
+ | ---------------------------------- first implementation here
+...
+LL | impl SadBee for fn(&'static ()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a> fn(&'a ())`
+ |
+ = note: `#[warn(coherence_leak_check)]` on by default
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
+ = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
+
+error[E0308]: mismatched types
+ --> $DIR/invariant.rs:27:5
+ |
+LL | v
+ | ^ one type is more general than the other
+ |
+ = note: expected reference `&'static Foo<fn(&'static ())>`
+ found reference `&'static Foo<for<'a> fn(&'a ())>`
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0308`.
|
= help: the following implementations were found:
<A<7_usize> as Bar<N>>
-note: required by `A`
- --> $DIR/unused-substs-1.rs:7:1
+note: required by a bound in `A`
+ --> $DIR/unused-substs-1.rs:9:11
|
-LL | / struct A<const N: usize>
-LL | | where
-LL | | A<N>: Bar<N>;
- | |_________________^
+LL | A<N>: Bar<N>;
+ | ^^^^^^ required by this bound in `A`
error: aborting due to previous error
// Regression test for issue 90013.
// check-pass
-#![allow(incomplete_features)]
#![feature(inline_const)]
fn main() {
// run-pass
#![feature(inline_const)]
-#![allow(unused, incomplete_features)]
+#![allow(unused)]
// Some type that is not copyable.
struct Bar;
#[repr(simd)] struct i8x1(i8);
#[repr(simd)] struct u16x2(u16, u16);
-#[repr(simd)] struct f32x4(f32, f32, f32, f32);
+// Make some of them array types to ensure those also work.
+#[repr(simd)] struct i8x1_arr([i8; 1]);
+#[repr(simd)] struct f32x4([f32; 4]);
extern "platform-intrinsic" {
#[rustc_const_stable(feature = "foo", since = "1.3.37")]
assert_eq!(X0, 42);
assert_eq!(Y0, 42);
}
+ {
+ const U: i8x1_arr = i8x1_arr([13]);
+ const V: i8x1_arr = unsafe { simd_insert(U, 0_u32, 42_i8) };
+ const X0: i8 = V.0[0];
+ const Y0: i8 = unsafe { simd_extract(V, 0) };
+ assert_eq!(X0, 42);
+ assert_eq!(Y0, 42);
+ }
{
const U: u16x2 = u16x2(13, 14);
const V: u16x2 = unsafe { simd_insert(U, 1_u32, 42_u16) };
assert_eq!(Y1, 42);
}
{
- const U: f32x4 = f32x4(13., 14., 15., 16.);
+ const U: f32x4 = f32x4([13., 14., 15., 16.]);
const V: f32x4 = unsafe { simd_insert(U, 1_u32, 42_f32) };
- const X0: f32 = V.0;
- const X1: f32 = V.1;
- const X2: f32 = V.2;
- const X3: f32 = V.3;
+ const X0: f32 = V.0[0];
+ const X1: f32 = V.0[1];
+ const X2: f32 = V.0[2];
+ const X3: f32 = V.0[3];
const Y0: f32 = unsafe { simd_extract(V, 0) };
const Y1: f32 = unsafe { simd_extract(V, 1) };
const Y2: f32 = unsafe { simd_extract(V, 2) };
--- /dev/null
+ #![l=|x|[b;x ]] //~ ERROR unexpected token: `|x| [b; x]`
+//~^ ERROR cannot find attribute `l` in this scope
+//~^^ ERROR attempt to use a non-constant value in a constant [E0435]
+//~^^^ ERROR cannot find value `b` in this scope [E0425]
+
+// notice the space at the start,
+// we can't attach any attributes to this file because it needs to be at the start
+
+// this example has been slightly modified (adding ]] at the end), so that it actually works here
+// it still produces the same issue though
+
+fn main() {}
--- /dev/null
+error: unexpected token: `|x| [b; x]`
+ --> $DIR/issue-90878-2.rs:1:7
+ |
+LL | #![l=|x|[b;x ]]
+ | ^^^^^^^^^
+
+error: cannot find attribute `l` in this scope
+ --> $DIR/issue-90878-2.rs:1:5
+ |
+LL | #![l=|x|[b;x ]]
+ | ^
+
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/issue-90878-2.rs:1:13
+ |
+LL | #![l=|x|[b;x ]]
+ | - ^
+ | |
+ | this would need to be a `const`
+
+error[E0425]: cannot find value `b` in this scope
+ --> $DIR/issue-90878-2.rs:1:11
+ |
+LL | #![l=|x|[b;x ]]
+ | ^ help: a local variable with a similar name exists: `x`
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0425, E0435.
+For more information about an error, try `rustc --explain E0425`.
--- /dev/null
+
+fn main() {
+ |x: usize| [0; x]; //~ ERROR attempt to use a non-constant value in a constant [E0435]
+ // (note the newline before "fn")
+}
+// ignore-tidy-leading-newlines
--- /dev/null
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/issue-90878-3.rs:3:20
+ |
+LL | |x: usize| [0; x];
+ | - ^
+ | |
+ | this would need to be a `const`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0435`.
--- /dev/null
+ fn main() {
+ |x: usize| [0; x]; //~ ERROR attempt to use a non-constant value in a constant [E0435]
+ // (note the space before "fn")
+}
--- /dev/null
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/issue-90878.rs:2:20
+ |
+LL | |x: usize| [0; x];
+ | - ^
+ | |
+ | this would need to be a `const`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0435`.
--- /dev/null
+fn main() {
+ let x = 5;
+ const Y: i32 = x; //~ ERROR attempt to use a non-constant value in a constant [E0435]
+
+ let x = 5;
+ let _ = [0; x]; //~ ERROR attempt to use a non-constant value in a constant [E0435]
+}
--- /dev/null
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/non-const-value-in-const.rs:3:20
+ |
+LL | const Y: i32 = x;
+ | ------- ^ non-constant value
+ | |
+ | help: consider using `let` instead of `const`: `let Y`
+
+error[E0435]: attempt to use a non-constant value in a constant
+ --> $DIR/non-const-value-in-const.rs:6:17
+ |
+LL | let x = 5;
+ | ----- help: consider using `const` instead of `let`: `const x`
+...
+LL | let _ = [0; x];
+ | ^ non-constant value
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0435`.
+++ /dev/null
-// run-pass
-
-#![allow(unused_must_use)]
-#![allow(stable_features)]
-#![allow(deprecated)]
-#![allow(unused_imports)]
-// compile-flags:--test
-// ignore-emscripten no processes
-// ignore-sgx no processes
-// ignore-vxworks no 'cat' and 'sleep'
-
-// N.B., these tests kill child processes. Valgrind sees these children as leaking
-// memory, which makes for some *confusing* logs. That's why these are here
-// instead of in std.
-
-#![feature(rustc_private, duration)]
-
-extern crate libc;
-
-use std::process::{self, Command, Child, Output, Stdio};
-use std::str;
-use std::sync::mpsc::channel;
-use std::thread;
-use std::time::Duration;
-
-macro_rules! t {
- ($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("error: {}", e) })
-}
-
-#[test]
-fn test_destroy_once() {
- let mut p = sleeper();
- t!(p.kill());
-}
-
-#[cfg(unix)]
-pub fn sleeper() -> Child {
- t!(Command::new("sleep").arg("1000").spawn())
-}
-#[cfg(windows)]
-pub fn sleeper() -> Child {
- // There's a `timeout` command on windows, but it doesn't like having
- // its output piped, so instead just ping ourselves a few times with
- // gaps in between so we're sure this process is alive for awhile
- t!(Command::new("ping").arg("127.0.0.1").arg("-n").arg("1000").spawn())
-}
-
-#[test]
-fn test_destroy_twice() {
- let mut p = sleeper();
- t!(p.kill()); // this shouldn't crash...
- let _ = p.kill(); // ...and nor should this (and nor should the destructor)
-}
-
-#[test]
-fn test_destroy_actually_kills() {
- let cmd = if cfg!(windows) {
- "cmd"
- } else if cfg!(target_os = "android") {
- "/system/bin/cat"
- } else {
- "cat"
- };
-
- // this process will stay alive indefinitely trying to read from stdin
- let mut p = t!(Command::new(cmd)
- .stdin(Stdio::piped())
- .spawn());
-
- t!(p.kill());
-
- // Don't let this test time out, this should be quick
- let (tx, rx) = channel();
- thread::spawn(move|| {
- thread::sleep_ms(1000);
- if rx.try_recv().is_err() {
- process::exit(1);
- }
- });
- let code = t!(p.wait()).code();
- if cfg!(windows) {
- assert!(code.is_some());
- } else {
- assert!(code.is_none());
- }
- tx.send(());
-}
+++ /dev/null
-// run-pass
-// compile-flags:-C target-feature=+crt-static
-// only-msvc
-
-#[cfg(target_feature = "crt-static")]
-fn main() {}
+++ /dev/null
-// run-pass
-// Regression test for #15477. This test just needs to compile.
-
-// pretty-expanded FIXME #23616
-
-trait Chromosome<X: Chromosome<i32>> {
-}
-
-impl Chromosome<i32> for i32 { }
-
-fn main() { }
LL | Bar::<NotClone> { x: 1 }.clone();
| ^^^^^ method cannot be called on `Bar<NotClone>` due to unsatisfied trait bounds
|
- = note: the following trait bounds were not satisfied:
- `NotClone: Clone`
- which is required by `Bar<NotClone>: Clone`
+note: the following trait bounds were not satisfied because of the requirements of the implementation of `Clone` for `_`:
+ `NotClone: Clone`
+ --> $DIR/derive-assoc-type-not-impl.rs:6:10
+ |
+LL | #[derive(Clone)]
+ | ^^^^^
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `clone`, perhaps you need to implement it:
candidate #1: `Clone`
+ = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider annotating `NotClone` with `#[derive(Clone)]`
|
LL | #[derive(Clone)]
LL | x: Error
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
|
-note: required by `clone`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | fn clone(&self) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | Error
| ^^^^^ the trait `Clone` is not implemented for `Error`
|
-note: required by `clone`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | fn clone(&self) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | x: Error
| ^^^^^^^^ the trait `Clone` is not implemented for `Error`
|
-note: required by `clone`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | fn clone(&self) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | Error
| ^^^^^ the trait `Clone` is not implemented for `Error`
|
-note: required by `clone`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | fn clone(&self) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | x: Error
| ^^^^^^^^ the trait `Default` is not implemented for `Error`
|
-note: required by `std::default::Default::default`
- --> $SRC_DIR/core/src/default.rs:LL:COL
- |
-LL | fn default() -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | Error
| ^^^^^ the trait `Default` is not implemented for `Error`
|
-note: required by `std::default::Default::default`
- --> $SRC_DIR/core/src/default.rs:LL:COL
- |
-LL | fn default() -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | x: Error
| ^^^^^^^^ the trait `Hash` is not implemented for `Error`
|
-note: required by a bound in `std::hash::Hash::hash`
- --> $SRC_DIR/core/src/hash/mod.rs:LL:COL
- |
-LL | fn hash<H: Hasher>(&self, state: &mut H);
- | ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | Error
| ^^^^^ the trait `Hash` is not implemented for `Error`
|
-note: required by a bound in `std::hash::Hash::hash`
- --> $SRC_DIR/core/src/hash/mod.rs:LL:COL
- |
-LL | fn hash<H: Hasher>(&self, state: &mut H);
- | ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | x: Error
| ^^^^^^^^ the trait `Hash` is not implemented for `Error`
|
-note: required by a bound in `std::hash::Hash::hash`
- --> $SRC_DIR/core/src/hash/mod.rs:LL:COL
- |
-LL | fn hash<H: Hasher>(&self, state: &mut H);
- | ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | Error
| ^^^^^ the trait `Hash` is not implemented for `Error`
|
-note: required by a bound in `std::hash::Hash::hash`
- --> $SRC_DIR/core/src/hash/mod.rs:LL:COL
- |
-LL | fn hash<H: Hasher>(&self, state: &mut H);
- | ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | x: Error
| ^^^^^^^^ the trait `Ord` is not implemented for `Error`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | Error
| ^^^^^ the trait `Ord` is not implemented for `Error`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | x: Error
| ^^^^^^^^ the trait `Ord` is not implemented for `Error`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | Error
| ^^^^^ the trait `Ord` is not implemented for `Error`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
| ^^^^^^^^ no implementation for `Error < Error` and `Error > Error`
|
= help: the trait `PartialOrd` is not implemented for `Error`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
| ^^^^^ no implementation for `Error < Error` and `Error > Error`
|
= help: the trait `PartialOrd` is not implemented for `Error`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
| ^^^^^^^^ no implementation for `Error < Error` and `Error > Error`
|
= help: the trait `PartialOrd` is not implemented for `Error`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
| ^^^^^ no implementation for `Error < Error` and `Error > Error`
|
= help: the trait `PartialOrd` is not implemented for `Error`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
LL | x: NoCloneOrEq
| ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoCloneOrEq`
|
-note: required by `clone`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | fn clone(&self) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 3 previous errors
--- /dev/null
+enum Hey<A, B> {
+ A(A),
+ B(B),
+}
+
+fn f() {}
+
+fn a() -> Option<()> {
+ while false {
+ //~^ ERROR mismatched types
+ f();
+ }
+ //~^ HELP try adding an expression
+}
+
+fn b() -> Result<(), ()> {
+ f()
+ //~^ ERROR mismatched types
+ //~| HELP try adding an expression
+}
+
+fn main() {
+ let _: Option<()> = while false {};
+ //~^ ERROR mismatched types
+ //~| HELP try wrapping
+ let _: Option<()> = {
+ while false {}
+ //~^ ERROR mismatched types
+ //~| HELP try adding an expression
+ };
+ let _: Result<i32, i32> = 1;
+ //~^ ERROR mismatched types
+ //~| HELP try wrapping
+ let _: Option<i32> = 1;
+ //~^ ERROR mismatched types
+ //~| HELP try wrapping
+ let _: Hey<i32, i32> = 1;
+ //~^ ERROR mismatched types
+ //~| HELP try wrapping
+ let _: Hey<i32, bool> = false;
+ //~^ ERROR mismatched types
+ //~| HELP try wrapping
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:9:5
+ |
+LL | fn a() -> Option<()> {
+ | ---------- expected `Option<()>` because of return type
+LL | / while false {
+LL | |
+LL | | f();
+LL | | }
+ | |_____^ expected enum `Option`, found `()`
+ |
+ = note: expected enum `Option<()>`
+ found unit type `()`
+help: try adding an expression at the end of the block
+ |
+LL ~ }
+LL + None
+ |
+LL ~ }
+LL + Some(())
+ |
+
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:17:5
+ |
+LL | fn b() -> Result<(), ()> {
+ | -------------- expected `Result<(), ()>` because of return type
+LL | f()
+ | ^^^ expected enum `Result`, found `()`
+ |
+ = note: expected enum `Result<(), ()>`
+ found unit type `()`
+help: try adding an expression at the end of the block
+ |
+LL ~ f();
+LL + Ok(())
+ |
+
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:23:25
+ |
+LL | let _: Option<()> = while false {};
+ | ---------- ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
+ | |
+ | expected due to this
+ |
+ = note: expected enum `Option<()>`
+ found unit type `()`
+help: try wrapping the expression in `Some`
+ |
+LL | let _: Option<()> = Some(while false {});
+ | +++++ +
+
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:27:9
+ |
+LL | while false {}
+ | ^^^^^^^^^^^^^^ expected enum `Option`, found `()`
+ |
+ = note: expected enum `Option<()>`
+ found unit type `()`
+help: try adding an expression at the end of the block
+ |
+LL ~ while false {}
+LL + None
+ |
+LL ~ while false {}
+LL + Some(())
+ |
+
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:31:31
+ |
+LL | let _: Result<i32, i32> = 1;
+ | ---------------- ^ expected enum `Result`, found integer
+ | |
+ | expected due to this
+ |
+ = note: expected enum `Result<i32, i32>`
+ found type `{integer}`
+help: try wrapping the expression in a variant of `Result`
+ |
+LL | let _: Result<i32, i32> = Ok(1);
+ | +++ +
+LL | let _: Result<i32, i32> = Err(1);
+ | ++++ +
+
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:34:26
+ |
+LL | let _: Option<i32> = 1;
+ | ----------- ^ expected enum `Option`, found integer
+ | |
+ | expected due to this
+ |
+ = note: expected enum `Option<i32>`
+ found type `{integer}`
+help: try wrapping the expression in `Some`
+ |
+LL | let _: Option<i32> = Some(1);
+ | +++++ +
+
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:37:28
+ |
+LL | let _: Hey<i32, i32> = 1;
+ | ------------- ^ expected enum `Hey`, found integer
+ | |
+ | expected due to this
+ |
+ = note: expected enum `Hey<i32, i32>`
+ found type `{integer}`
+help: try wrapping the expression in a variant of `Hey`
+ |
+LL | let _: Hey<i32, i32> = Hey::A(1);
+ | +++++++ +
+LL | let _: Hey<i32, i32> = Hey::B(1);
+ | +++++++ +
+
+error[E0308]: mismatched types
+ --> $DIR/compatible-variants.rs:40:29
+ |
+LL | let _: Hey<i32, bool> = false;
+ | -------------- ^^^^^ expected enum `Hey`, found `bool`
+ | |
+ | expected due to this
+ |
+ = note: expected enum `Hey<i32, bool>`
+ found type `bool`
+help: try wrapping the expression in `Hey::B`
+ |
+LL | let _: Hey<i32, bool> = Hey::B(false);
+ | +++++++ +
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
<i8 as Foo<u32>>
<i8 as Foo<u64>>
<i8 as Foo<u8>>
-note: required by `Foo::bar`
- --> $DIR/issue-39802-show-5-trait-impls.rs:2:5
- |
-LL | fn bar(&self){}
- | ^^^^^^^^^^^^^
error[E0277]: the trait bound `u8: Foo<i32>` is not satisfied
--> $DIR/issue-39802-show-5-trait-impls.rs:25:21
<u8 as Foo<u16>>
<u8 as Foo<u32>>
<u8 as Foo<u64>>
-note: required by `Foo::bar`
- --> $DIR/issue-39802-show-5-trait-impls.rs:2:5
- |
-LL | fn bar(&self){}
- | ^^^^^^^^^^^^^
error[E0277]: the trait bound `bool: Foo<i32>` is not satisfied
--> $DIR/issue-39802-show-5-trait-impls.rs:26:21
<bool as Foo<u16>>
<bool as Foo<u32>>
and 2 others
-note: required by `Foo::bar`
- --> $DIR/issue-39802-show-5-trait-impls.rs:2:5
- |
-LL | fn bar(&self){}
- | ^^^^^^^^^^^^^
error: aborting due to 3 previous errors
let n: usize = 42;
this_function_expects_a_double_option(n);
//~^ ERROR mismatched types
- //~| HELP try using a variant of the expected enum
+ //~| HELP try wrapping the expression in a variant of `DoubleOption`
}
|
= note: expected enum `DoubleOption<_>`
found type `usize`
-help: try using a variant of the expected enum
+help: try wrapping the expression in a variant of `DoubleOption`
|
-LL | this_function_expects_a_double_option(DoubleOption::AlternativeSome(n));
- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LL | this_function_expects_a_double_option(DoubleOption::FirstSome(n));
- | ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | ++++++++++++++++++++++++ +
+LL | this_function_expects_a_double_option(DoubleOption::AlternativeSome(n));
+ | ++++++++++++++++++++++++++++++ +
error[E0308]: mismatched types
--> $DIR/issue-42764.rs:27:33
--- /dev/null
+// run-pass
+
+use std::cell::RefCell;
+
+struct S<'a>(i32, &'a RefCell<Vec<i32>>);
+
+impl<'a> Drop for S<'a> {
+ fn drop(&mut self) {
+ self.1.borrow_mut().push(self.0);
+ }
+}
+
+fn test(drops: &RefCell<Vec<i32>>) {
+ let mut foo = None;
+ let pfoo: *mut _ = &mut foo;
+
+ match foo {
+ None => (),
+ _ => return,
+ }
+
+ // Both S(0) and S(1) should be dropped, but aren't.
+ unsafe { *pfoo = Some((S(0, drops), S(1, drops))); }
+
+ match foo {
+ Some((_x, _)) => {}
+ _ => {}
+ }
+}
+
+fn main() {
+ let drops = RefCell::new(Vec::new());
+ test(&drops);
+
+ // Ideally, we want this...
+ //assert_eq!(*drops.borrow(), &[0, 1]);
+
+ // But the delayed access through the raw pointer confuses drop elaboration,
+ // causing S(1) to be leaked.
+ assert_eq!(*drops.borrow(), &[0]);
+}
--- /dev/null
+// run-pass
+
+use std::cell::RefCell;
+
+struct S<'a>(i32, &'a RefCell<Vec<i32>>);
+
+impl<'a> Drop for S<'a> {
+ fn drop(&mut self) {
+ self.1.borrow_mut().push(self.0);
+ }
+}
+
+fn test(drops: &RefCell<Vec<i32>>) {
+ let mut foo = None;
+ match foo {
+ None => (),
+ _ => return,
+ }
+
+ *(&mut foo) = Some((S(0, drops), S(1, drops))); // Both S(0) and S(1) should be dropped
+
+ match foo {
+ Some((_x, _)) => {}
+ _ => {}
+ }
+}
+
+fn main() {
+ let drops = RefCell::new(Vec::new());
+ test(&drops);
+ assert_eq!(*drops.borrow(), &[0, 1]);
+}
--- /dev/null
+// run-pass
+
+#![allow(stable_features)]
+#![allow(unused_imports)]
+// Test that cleanup scope for temporaries created in a match
+// arm is confined to the match arm itself.
+
+// pretty-expanded FIXME #23616
+
+#![feature(os)]
+
+use std::os;
+
+struct Test { x: isize }
+
+impl Test {
+ fn get_x(&self) -> Option<Box<isize>> {
+ Some(Box::new(self.x))
+ }
+}
+
+fn do_something(t: &Test) -> isize {
+
+ // The cleanup scope for the result of `t.get_x()` should be the
+ // arm itself and not the match, otherwise we'll (potentially) get
+ // a crash trying to free an uninitialized stack slot.
+
+ match t {
+ &Test { x: 2 } if t.get_x().is_some() => {
+ t.x * 2
+ }
+ _ => { 22 }
+ }
+}
+
+pub fn main() {
+ let t = Test { x: 1 };
+ do_something(&t);
+}
+++ /dev/null
-type A0 = dyn;
-//~^ ERROR cannot find type `dyn` in this scope
-type A1 = dyn::dyn;
-//~^ ERROR use of undeclared crate or module `dyn`
-type A2 = dyn<dyn, dyn>;
-//~^ ERROR cannot find type `dyn` in this scope
-//~| ERROR cannot find type `dyn` in this scope
-//~| ERROR cannot find type `dyn` in this scope
-type A3 = dyn<<dyn as dyn>::dyn>;
-//~^ ERROR cannot find type `dyn` in this scope
-//~| ERROR cannot find type `dyn` in this scope
-//~| ERROR use of undeclared crate or module `dyn`
-
-fn main() {}
+++ /dev/null
-error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
- --> $DIR/dyn-trait-compatibility.rs:3:11
- |
-LL | type A1 = dyn::dyn;
- | ^^^ use of undeclared crate or module `dyn`
-
-error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
- --> $DIR/dyn-trait-compatibility.rs:9:23
- |
-LL | type A3 = dyn<<dyn as dyn>::dyn>;
- | ^^^ use of undeclared crate or module `dyn`
-
-error[E0412]: cannot find type `dyn` in this scope
- --> $DIR/dyn-trait-compatibility.rs:1:11
- |
-LL | type A0 = dyn;
- | ^^^ not found in this scope
-
-error[E0412]: cannot find type `dyn` in this scope
- --> $DIR/dyn-trait-compatibility.rs:5:11
- |
-LL | type A2 = dyn<dyn, dyn>;
- | ^^^ not found in this scope
-
-error[E0412]: cannot find type `dyn` in this scope
- --> $DIR/dyn-trait-compatibility.rs:5:15
- |
-LL | type A2 = dyn<dyn, dyn>;
- | - ^^^ not found in this scope
- | |
- | help: you might be missing a type parameter: `<dyn>`
-
-error[E0412]: cannot find type `dyn` in this scope
- --> $DIR/dyn-trait-compatibility.rs:5:20
- |
-LL | type A2 = dyn<dyn, dyn>;
- | - ^^^ not found in this scope
- | |
- | help: you might be missing a type parameter: `<dyn>`
-
-error[E0412]: cannot find type `dyn` in this scope
- --> $DIR/dyn-trait-compatibility.rs:9:11
- |
-LL | type A3 = dyn<<dyn as dyn>::dyn>;
- | ^^^ not found in this scope
-
-error[E0412]: cannot find type `dyn` in this scope
- --> $DIR/dyn-trait-compatibility.rs:9:16
- |
-LL | type A3 = dyn<<dyn as dyn>::dyn>;
- | - ^^^ not found in this scope
- | |
- | help: you might be missing a type parameter: `<dyn>`
-
-error: aborting due to 8 previous errors
-
-Some errors have detailed explanations: E0412, E0433.
-For more information about an error, try `rustc --explain E0412`.
+++ /dev/null
-// run-pass
-
-#![allow(non_camel_case_types)]
-#![allow(dead_code)]
-// pretty-expanded FIXME #23616
-
-trait thing<A> {
- fn foo(&self) -> Option<A>;
-}
-impl<A> thing<A> for isize {
- fn foo(&self) -> Option<A> { None }
-}
-fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() }
-
-struct A { a: isize }
-
-pub fn main() {
- let _x: Option<f64> = foo_func(0);
-}
+++ /dev/null
-// run-pass
-
-#![allow(unused_mut)]
-#![allow(unused_assignments)]
-#![allow(unused_variables)]
-// edition:2015
-// aux-build:edition-kw-macro-2018.rs
-
-#[macro_use]
-extern crate edition_kw_macro_2018;
-
-pub fn check_async() {
- let mut async = 1; // OK
- let mut r#async = 1; // OK
-
- r#async = consumes_async!(async); // OK
- // r#async = consumes_async!(r#async); // ERROR, not a match
- // r#async = consumes_async_raw!(async); // ERROR, not a match
- r#async = consumes_async_raw!(r#async); // OK
-
- if passes_ident!(async) == 1 {} // OK
- if passes_ident!(r#async) == 1 {} // OK
- // one_async::async(); // ERROR, unresolved name
- // one_async::r#async(); // ERROR, unresolved name
- two_async::async(); // OK
- two_async::r#async(); // OK
-}
-
-mod one_async {
- // produces_async! {} // ERROR, reserved
-}
-mod two_async {
- produces_async_raw! {} // OK
-}
-
-fn main() {}
+++ /dev/null
-// run-pass
-
-#![allow(unused_assignments)]
-// edition:2018
-// aux-build:edition-kw-macro-2018.rs
-
-#[macro_use]
-extern crate edition_kw_macro_2018;
-
-pub fn check_async() {
- // let mut async = 1; // ERROR, reserved
- let mut r#async = 1; // OK
-
- r#async = consumes_async!(async); // OK
- // r#async = consumes_async!(r#async); // ERROR, not a match
- // r#async = consumes_async_raw!(async); // ERROR, not a match
- r#async = consumes_async_raw!(r#async); // OK
-
- // if passes_ident!(async) == 1 {} // ERROR, reserved
- if passes_ident!(r#async) == 1 {} // OK
- // one_async::async(); // ERROR, reserved
- // one_async::r#async(); // ERROR, unresolved name
- // two_async::async(); // ERROR, reserved
- two_async::r#async(); // OK
-}
-
-mod one_async {
- // produces_async! {} // ERROR, reserved
-}
-mod two_async {
- produces_async_raw! {} // OK
-}
-
-fn main() {}
--- /dev/null
+// run-pass
+
+#![allow(unused_mut)]
+#![allow(unused_assignments)]
+#![allow(unused_variables)]
+// edition:2015
+// aux-build:edition-kw-macro-2018.rs
+
+#[macro_use]
+extern crate edition_kw_macro_2018;
+
+pub fn check_async() {
+ let mut async = 1; // OK
+ let mut r#async = 1; // OK
+
+ r#async = consumes_async!(async); // OK
+ // r#async = consumes_async!(r#async); // ERROR, not a match
+ // r#async = consumes_async_raw!(async); // ERROR, not a match
+ r#async = consumes_async_raw!(r#async); // OK
+
+ if passes_ident!(async) == 1 {} // OK
+ if passes_ident!(r#async) == 1 {} // OK
+ // one_async::async(); // ERROR, unresolved name
+ // one_async::r#async(); // ERROR, unresolved name
+ two_async::async(); // OK
+ two_async::r#async(); // OK
+}
+
+mod one_async {
+ // produces_async! {} // ERROR, reserved
+}
+mod two_async {
+ produces_async_raw! {} // OK
+}
+
+fn main() {}
--- /dev/null
+// run-pass
+
+#![allow(unused_assignments)]
+// edition:2018
+// aux-build:edition-kw-macro-2018.rs
+
+#[macro_use]
+extern crate edition_kw_macro_2018;
+
+pub fn check_async() {
+ // let mut async = 1; // ERROR, reserved
+ let mut r#async = 1; // OK
+
+ r#async = consumes_async!(async); // OK
+ // r#async = consumes_async!(r#async); // ERROR, not a match
+ // r#async = consumes_async_raw!(async); // ERROR, not a match
+ r#async = consumes_async_raw!(r#async); // OK
+
+ // if passes_ident!(async) == 1 {} // ERROR, reserved
+ if passes_ident!(r#async) == 1 {} // OK
+ // one_async::async(); // ERROR, reserved
+ // one_async::r#async(); // ERROR, unresolved name
+ // two_async::async(); // ERROR, reserved
+ two_async::r#async(); // OK
+}
+
+mod one_async {
+ // produces_async! {} // ERROR, reserved
+}
+mod two_async {
+ produces_async_raw! {} // OK
+}
+
+fn main() {}
--- /dev/null
+#![deny(unused_attributes)]
+#![allow()] //~ ERROR unused attribute
+#![warn()] //~ ERROR unused attribute
+#![deny()] //~ ERROR unused attribute
+#![forbid()] //~ ERROR unused attribute
+#![feature()] //~ ERROR unused attribute
+
+#[repr()] //~ ERROR unused attribute
+pub struct S;
+
+#[target_feature()] //~ ERROR unused attribute
+pub unsafe fn foo() {}
+
+fn main() {}
--- /dev/null
+error: unused attribute
+ --> $DIR/empty-attributes.rs:8:1
+ |
+LL | #[repr()]
+ | ^^^^^^^^^ help: remove this attribute
+ |
+note: the lint level is defined here
+ --> $DIR/empty-attributes.rs:1:9
+ |
+LL | #![deny(unused_attributes)]
+ | ^^^^^^^^^^^^^^^^^
+ = note: attribute `repr` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:11:1
+ |
+LL | #[target_feature()]
+ | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `target_feature` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:2:1
+ |
+LL | #![allow()]
+ | ^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `allow` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:3:1
+ |
+LL | #![warn()]
+ | ^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `warn` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:4:1
+ |
+LL | #![deny()]
+ | ^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `deny` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:5:1
+ |
+LL | #![forbid()]
+ | ^^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `forbid` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:6:1
+ |
+LL | #![feature()]
+ | ^^^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `feature` with an empty list has no effect
+
+error: aborting due to 7 previous errors
+
|
help: `E::Empty4` is a unit variant, you need to write it without the parentheses
|
-LL | let e4 = E::Empty4;
- | ~~~~~~~~~
+LL - let e4 = E::Empty4();
+LL + let e4 = E::Empty4;
+ |
error[E0618]: expected function, found `empty_struct::XEmpty2`
--> $DIR/empty-struct-unit-expr.rs:18:15
|
help: `XE::XEmpty4` is a unit variant, you need to write it without the parentheses
|
-LL | let xe4 = XE::XEmpty4;
- | ~~~~~~~~~~~
+LL - let xe4 = XE::XEmpty4();
+LL + let xe4 = XE::XEmpty4;
+ |
error: aborting due to 4 previous errors
| ^^^ ^
= note: 127 redundant requirements hidden
= note: required because of the requirements on the impl of `Foo` for `Bar<T>`
-note: required by a bound in `Foo`
- --> $DIR/E0275.rs:1:1
- |
-LL | trait Foo {}
- | ^^^^^^^^^ required by this bound in `Foo`
error: aborting due to previous error
error[E0276]: impl has stricter requirements than trait
- --> $DIR/E0276.rs:6:5
+ --> $DIR/E0276.rs:6:30
|
LL | fn foo<T>(x: T);
| ---------------- definition of `foo` from trait
...
LL | fn foo<T>(x: T) where T: Copy {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Copy`
+ | ^^^^ impl has extra requirement `T: Copy`
error: aborting due to previous error
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Generator`
-note: required by `Generator::create`
- --> $DIR/E0283.rs:2:5
- |
-LL | fn create() -> u32;
- | ^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/E0283.rs:35:24
}
pub use foo as foo2;
-//~^ ERROR `foo` is private, and cannot be re-exported [E0365]
+//~^ ERROR `foo` is only public within the crate, and cannot be re-exported outside [E0365]
fn main() {}
-error[E0365]: `foo` is private, and cannot be re-exported
+error[E0365]: `foo` is only public within the crate, and cannot be re-exported outside
--> $DIR/E0365.rs:5:9
|
LL | pub use foo as foo2;
- | ^^^^^^^^^^^ re-export of private `foo`
+ | ^^^^^^^^^^^ re-export of crate public `foo`
|
= note: consider declaring type or module `foo` with `pub`
|
help: `X::Entry` is a unit variant, you need to write it without the parentheses
|
-LL | X::Entry;
- | ~~~~~~~~
+LL - X::Entry();
+LL + X::Entry;
+ |
error[E0618]: expected function, found `i32`
--> $DIR/E0618.rs:9:5
+++ /dev/null
-// In this test baz isn't resolved when called as foo.baz even though
-// it's called from inside foo. This is somewhat surprising and may
-// want to change eventually.
-
-mod foo {
- pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of undeclared crate or module `foo`
-
- fn baz() { }
-}
-
-fn main() { }
+++ /dev/null
-error[E0433]: failed to resolve: use of undeclared crate or module `foo`
- --> $DIR/export-fully-qualified.rs:6:20
- |
-LL | pub fn bar() { foo::baz(); }
- | ^^^ use of undeclared crate or module `foo`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0433`.
+++ /dev/null
-mod foo {
- pub fn x() { }
-
- enum Y { Y1 }
-}
-
-fn main() { let z = foo::Y::Y1; } //~ ERROR: enum `Y` is private
+++ /dev/null
-error[E0603]: enum `Y` is private
- --> $DIR/export-tag-variant.rs:7:26
- |
-LL | fn main() { let z = foo::Y::Y1; }
- | ^ private enum
- |
-note: the enum `Y` is defined here
- --> $DIR/export-tag-variant.rs:4:5
- |
-LL | enum Y { Y1 }
- | ^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0603`.
+++ /dev/null
-mod foo {
- pub fn x(y: isize) { log(debug, y); }
- //~^ ERROR cannot find function `log` in this scope
- //~| ERROR cannot find value `debug` in this scope
- fn z(y: isize) { log(debug, y); }
- //~^ ERROR cannot find function `log` in this scope
- //~| ERROR cannot find value `debug` in this scope
-}
-
-fn main() { foo::z(10); } //~ ERROR function `z` is private
+++ /dev/null
-error[E0425]: cannot find function `log` in this scope
- --> $DIR/export.rs:2:26
- |
-LL | pub fn x(y: isize) { log(debug, y); }
- | ^^^ not found in this scope
-
-error[E0425]: cannot find value `debug` in this scope
- --> $DIR/export.rs:2:30
- |
-LL | pub fn x(y: isize) { log(debug, y); }
- | ^^^^^ not found in this scope
-
-error[E0425]: cannot find function `log` in this scope
- --> $DIR/export.rs:5:22
- |
-LL | fn z(y: isize) { log(debug, y); }
- | ^^^ not found in this scope
-
-error[E0425]: cannot find value `debug` in this scope
- --> $DIR/export.rs:5:26
- |
-LL | fn z(y: isize) { log(debug, y); }
- | ^^^^^ not found in this scope
-
-error[E0603]: function `z` is private
- --> $DIR/export.rs:10:18
- |
-LL | fn main() { foo::z(10); }
- | ^ private function
- |
-note: the function `z` is defined here
- --> $DIR/export.rs:5:5
- |
-LL | fn z(y: isize) { log(debug, y); }
- | ^^^^^^^^^^^^^^
-
-error: aborting due to 5 previous errors
-
-Some errors have detailed explanations: E0425, E0603.
-For more information about an error, try `rustc --explain E0425`.
+++ /dev/null
-// run-pass
-// Regression test for issue #377
-
-
-struct A { a: isize }
-struct V { v: isize }
-
-pub fn main() {
- let a = { let b = A {a: 3}; b };
- assert_eq!(a.a, 3);
- let c = { let d = V {v: 3}; d };
- assert_eq!(c.v, 3);
-}
| |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
|
= help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
+note: required by a bound in `Option::<T>::and_then`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ |
+LL | pub fn and_then<U, F: FnOnce(T) -> Option<U>>(self, f: F) -> Option<U> {
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::and_then`
error: aborting due to 2 previous errors
--- /dev/null
+#![crate_type = "lib"]
+
+struct Bar;
+
+impl Bar {
+ #[no_mangle]
+ fn bar() -> u8 {
+ 2
+ }
+}
+
+trait Foo {
+ fn baz() -> u8;
+}
+
+impl Foo for Bar {
+ #[no_mangle]
+ fn baz() -> u8 {
+ 3
+ }
+}
--- /dev/null
+// aux-build: no-mangle-associated-fn.rs
+// run-pass
+
+extern crate no_mangle_associated_fn;
+
+struct Foo;
+
+impl Foo {
+ #[no_mangle]
+ fn foo() -> u8 {
+ 1
+ }
+}
+
+trait Bar {
+ fn qux() -> u8;
+}
+
+impl Bar for Foo {
+ #[no_mangle]
+ fn qux() -> u8 {
+ 4
+ }
+}
+
+fn main() {
+ extern "Rust" {
+ fn foo() -> u8;
+ fn bar() -> u8;
+ fn baz() -> u8;
+ fn qux() -> u8;
+ }
+ assert_eq!(unsafe { foo() }, 1);
+ assert_eq!(unsafe { bar() }, 2);
+ assert_eq!(unsafe { baz() }, 3);
+ assert_eq!(unsafe { qux() }, 4);
+}
LL | type A: Iterator<Item: Copy>;
| ^^^^ the trait `Copy` is not implemented for `<<Self as _Tr3>::A as Iterator>::Item`
|
-note: required by a bound in `Copy`
- --> $SRC_DIR/core/src/marker.rs:LL:COL
- |
-LL | / pub trait Copy: Clone {
-LL | | // Empty.
-LL | | }
- | |_^ required by this bound in `Copy`
help: consider further restricting the associated type
|
LL | trait _Tr3 where <<Self as _Tr3>::A as Iterator>::Item: Copy {
--- /dev/null
+fn main() {
+ let const { () } = ();
+ //~^ ERROR inline-const in pattern position is experimental [E0658]
+}
--- /dev/null
+error[E0658]: inline-const in pattern position is experimental
+ --> $DIR/feature-gate-inline_const_pat.rs:2:9
+ |
+LL | let const { () } = ();
+ | ^^^^^
+ |
+ = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
+ = help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
//~^ ERROR: `start` attribute can only be used on functions
}
+#[repr(C)]
+//~^ ERROR: attribute should be applied to a struct, enum, or union
+mod repr {
+//~^ NOTE not a struct, enum, or union
+ mod inner { #![repr(C)] }
+ //~^ ERROR: attribute should be applied to a struct, enum, or union
+ //~| NOTE not a struct, enum, or union
+
+ #[repr(C)] fn f() { }
+ //~^ ERROR: attribute should be applied to a struct, enum, or union
+ //~| NOTE not a struct, enum, or union
+
+ struct S;
+
+ #[repr(C)] type T = S;
+ //~^ ERROR: attribute should be applied to a struct, enum, or union
+ //~| NOTE not a struct, enum, or union
+
+ #[repr(C)] impl S { }
+ //~^ ERROR: attribute should be applied to a struct, enum, or union
+ //~| NOTE not a struct, enum, or union
+}
+
fn main() {}
LL | | }
| |_- not a free function, impl method or static
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:8
+ |
+LL | #[repr(C)]
+ | ^
+LL |
+LL | / mod repr {
+LL | |
+LL | | mod inner { #![repr(C)] }
+LL | |
+... |
+LL | |
+LL | | }
+ | |_- not a struct, enum, or union
+
error: attribute should be applied to an `extern crate` item
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:1
|
LL | #[export_name = "2200"] fn bar() {}
| ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static
-error: aborting due to 34 previous errors
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:141:25
+ |
+LL | mod inner { #![repr(C)] }
+ | --------------------^---- not a struct, enum, or union
+
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:145:12
+ |
+LL | #[repr(C)] fn f() { }
+ | ^ ---------- not a struct, enum, or union
+
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:151:12
+ |
+LL | #[repr(C)] type T = S;
+ | ^ ----------- not a struct, enum, or union
+
+error[E0517]: attribute should be applied to a struct, enum, or union
+ --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:155:12
+ |
+LL | #[repr(C)] impl S { }
+ | ^ ---------- not a struct, enum, or union
+
+error: aborting due to 39 previous errors
-Some errors have detailed explanations: E0518, E0658.
-For more information about an error, try `rustc --explain E0518`.
+Some errors have detailed explanations: E0517, E0518, E0658.
+For more information about an error, try `rustc --explain E0517`.
impl S { }
}
-#[repr()]
-mod repr {
- mod inner { #![repr()] }
-
- #[repr()] fn f() { }
-
- struct S;
-
- #[repr()] type T = S;
-
- #[repr()] impl S { }
-}
-
#[path = "3800"]
mod path {
mod inner { #![path="3800"] }
| ^^^^^
warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:399:17
|
LL | mod inner { #![macro_escape] }
| ^^^^^^^^^^^^^^^^
= help: try an outer attribute: `#[macro_use]`
warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:409:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:396:1
|
LL | #[macro_escape]
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
warning: `#[automatically_derived]` only has an effect on items
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:278:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:265:1
|
LL | #[automatically_derived]
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: attribute should be applied to a free function, impl method or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:296:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:283:1
|
LL | #[no_mangle]
| ^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: `#[should_panic]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:336:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:323:1
|
LL | #[should_panic]
| ^^^^^^^^^^^^^^^
warning: `#[ignore]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:354:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:341:1
|
LL | #[ignore]
| ^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:389:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:376:1
|
LL | #[reexport_test_harness_main = "2900"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:429:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:416:1
|
LL | #[no_std]
| ^^^^^^^^^
warning: attribute should be applied to a function
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:465:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:452:1
|
LL | #[cold]
| ^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a foreign function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:481:1
|
LL | #[link_name = "1900"]
| ^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:520:1
|
LL | #[link_section = "1800"]
| ^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:624:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:611:1
|
LL | #[crate_name = "0900"]
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:643:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:630:1
|
LL | #[crate_type = "0800"]
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:662:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:649:1
|
LL | #[feature(x0600)]
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:669:1
|
LL | #[no_main]
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:714:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:1
|
LL | #[recursion_limit="0200"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:1
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:1
|
LL | #[type_length_limit="0100"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^
warning: `#[path]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:265:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:252:5
|
LL | #[path = "3800"] fn f() { }
| ^^^^^^^^^^^^^^^^
warning: `#[path]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:268:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:255:5
|
LL | #[path = "3800"] struct S;
| ^^^^^^^^^^^^^^^^
warning: `#[path]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:271:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:258:5
|
LL | #[path = "3800"] type T = S;
| ^^^^^^^^^^^^^^^^
warning: `#[path]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:274:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:261:5
|
LL | #[path = "3800"] impl S { }
| ^^^^^^^^^^^^^^^^
warning: `#[automatically_derived]` only has an effect on items
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:281:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:268:17
|
LL | mod inner { #![automatically_derived] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: `#[automatically_derived]` only has an effect on items
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:284:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:271:5
|
LL | #[automatically_derived] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: `#[automatically_derived]` only has an effect on items
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:287:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:274:5
|
LL | #[automatically_derived] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: `#[automatically_derived]` only has an effect on items
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:290:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:277:5
|
LL | #[automatically_derived] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^
warning: attribute should be applied to a free function, impl method or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:301:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:288:17
|
LL | mod inner { #![no_mangle] }
| ------------^^^^^^^^^^^^^-- not a free function, impl method or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a free function, impl method or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:308:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:295:5
|
LL | #[no_mangle] struct S;
| ^^^^^^^^^^^^ --------- not a free function, impl method or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a free function, impl method or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:313:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:300:5
|
LL | #[no_mangle] type T = S;
| ^^^^^^^^^^^^ ----------- not a free function, impl method or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a free function, impl method or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:318:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:305:5
|
LL | #[no_mangle] impl S { }
| ^^^^^^^^^^^^ ---------- not a free function, impl method or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a free function, impl method or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:324:9
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:311:9
|
LL | #[no_mangle] fn foo();
| ^^^^^^^^^^^^ --------- not a free function, impl method or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a free function, impl method or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:329:9
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:316:9
|
LL | #[no_mangle] fn bar() {}
| ^^^^^^^^^^^^ ----------- not a free function, impl method or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: `#[should_panic]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:339:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:326:17
|
LL | mod inner { #![should_panic] }
| ^^^^^^^^^^^^^^^^
warning: `#[should_panic]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:344:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:331:5
|
LL | #[should_panic] struct S;
| ^^^^^^^^^^^^^^^
warning: `#[should_panic]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:347:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:334:5
|
LL | #[should_panic] type T = S;
| ^^^^^^^^^^^^^^^
warning: `#[should_panic]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:350:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:337:5
|
LL | #[should_panic] impl S { }
| ^^^^^^^^^^^^^^^
warning: `#[ignore]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:357:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:344:17
|
LL | mod inner { #![ignore] }
| ^^^^^^^^^^
warning: `#[ignore]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:362:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:349:5
|
LL | #[ignore] struct S;
| ^^^^^^^^^
warning: `#[ignore]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:352:5
|
LL | #[ignore] type T = S;
| ^^^^^^^^^
warning: `#[ignore]` only has an effect on functions
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:368:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:355:5
|
LL | #[ignore] impl S { }
| ^^^^^^^^^
warning: `#[no_implicit_prelude]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:376:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:363:5
|
LL | #[no_implicit_prelude] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: `#[no_implicit_prelude]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:379:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:366:5
|
LL | #[no_implicit_prelude] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: `#[no_implicit_prelude]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:382:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:369:5
|
LL | #[no_implicit_prelude] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: `#[no_implicit_prelude]` only has an effect on modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:385:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:372:5
|
LL | #[no_implicit_prelude] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:392:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:379:17
|
LL | mod inner { #![reexport_test_harness_main="2900"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:395:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:382:5
|
LL | #[reexport_test_harness_main = "2900"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:385:5
|
LL | #[reexport_test_harness_main = "2900"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:401:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:388:5
|
LL | #[reexport_test_harness_main = "2900"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:404:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:391:5
|
LL | #[reexport_test_harness_main = "2900"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: `#[macro_escape]` only has an effect on `extern crate` and modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:416:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:403:5
|
LL | #[macro_escape] fn f() { }
| ^^^^^^^^^^^^^^^
warning: `#[macro_escape]` only has an effect on `extern crate` and modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:419:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:406:5
|
LL | #[macro_escape] struct S;
| ^^^^^^^^^^^^^^^
warning: `#[macro_escape]` only has an effect on `extern crate` and modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:422:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:409:5
|
LL | #[macro_escape] type T = S;
| ^^^^^^^^^^^^^^^
warning: `#[macro_escape]` only has an effect on `extern crate` and modules
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:425:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:412:5
|
LL | #[macro_escape] impl S { }
| ^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:419:17
|
LL | mod inner { #![no_std] }
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:435:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:422:5
|
LL | #[no_std] fn f() { }
| ^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:438:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:425:5
|
LL | #[no_std] struct S;
| ^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:441:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:428:5
|
LL | #[no_std] type T = S;
| ^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:444:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:431:5
|
LL | #[no_std] impl S { }
| ^^^^^^^^^
warning: attribute should be applied to a function
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:471:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:458:17
|
LL | mod inner { #![cold] }
| ------------^^^^^^^^-- not a function
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:478:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:465:5
|
LL | #[cold] struct S;
| ^^^^^^^ --------- not a function
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:483:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:470:5
|
LL | #[cold] type T = S;
| ^^^^^^^ ----------- not a function
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:475:5
|
LL | #[cold] impl S { }
| ^^^^^^^ ---------- not a function
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a foreign function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:500:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:5
|
LL | #[link_name = "1900"]
| ^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
help: try `#[link(name = "1900")]` instead
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:500:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:5
|
LL | #[link_name = "1900"]
| ^^^^^^^^^^^^^^^^^^^^^
warning: attribute should be applied to a foreign function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:507:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:17
|
LL | mod inner { #![link_name="1900"] }
| ------------^^^^^^^^^^^^^^^^^^^^-- not a foreign function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a foreign function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:499:5
|
LL | #[link_name = "1900"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a foreign function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:517:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:504:5
|
LL | #[link_name = "1900"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^ --------- not a foreign function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a foreign function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:522:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:509:5
|
LL | #[link_name = "1900"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^ ----------- not a foreign function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a foreign function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:527:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:514:5
|
LL | #[link_name = "1900"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:526:17
|
LL | mod inner { #![link_section="1800"] }
| ------------^^^^^^^^^^^^^^^^^^^^^^^-- not a function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:546:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5
|
LL | #[link_section = "1800"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:551:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:538:5
|
LL | #[link_section = "1800"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: attribute should be applied to a function or static
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:556:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:543:5
|
LL | #[link_section = "1800"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:627:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:17
|
LL | mod inner { #![crate_name="0900"] }
| ^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:630:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:617:5
|
LL | #[crate_name = "0900"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:633:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5
|
LL | #[crate_name = "0900"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:636:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:623:5
|
LL | #[crate_name = "0900"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5
|
LL | #[crate_name = "0900"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:633:17
|
LL | mod inner { #![crate_type="0800"] }
| ^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:649:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:636:5
|
LL | #[crate_type = "0800"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:5
|
LL | #[crate_type = "0800"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:655:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:642:5
|
LL | #[crate_type = "0800"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:645:5
|
LL | #[crate_type = "0800"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:17
|
LL | mod inner { #![feature(x0600)] }
| ^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:668:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:655:5
|
LL | #[feature(x0600)] fn f() { }
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:5
|
LL | #[feature(x0600)] struct S;
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:674:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:661:5
|
LL | #[feature(x0600)] type T = S;
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5
|
LL | #[feature(x0600)] impl S { }
| ^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:672:17
|
LL | mod inner { #![no_main] }
| ^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:675:5
|
LL | #[no_main] fn f() { }
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:678:5
|
LL | #[no_main] struct S;
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:694:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:681:5
|
LL | #[no_main] type T = S;
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:684:5
|
LL | #[no_main] impl S { }
| ^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:717:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:704:17
|
LL | mod inner { #![recursion_limit="0200"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:5
|
LL | #[recursion_limit="0200"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:710:5
|
LL | #[recursion_limit="0200"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:726:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:5
|
LL | #[recursion_limit="0200"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:729:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5
|
LL | #[recursion_limit="0200"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be in the root module
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:736:17
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:17
|
LL | mod inner { #![type_length_limit="0100"] }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:739:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:726:5
|
LL | #[type_length_limit="0100"] fn f() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:742:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:729:5
|
LL | #[type_length_limit="0100"] struct S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5
|
LL | #[type_length_limit="0100"] type T = S;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
- --> $DIR/issue-43106-gating-of-builtin-attrs.rs:748:5
+ --> $DIR/issue-43106-gating-of-builtin-attrs.rs:735:5
|
LL | #[type_length_limit="0100"] impl S { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+++ /dev/null
-fn main() {
- let x: f32 = 1; //~ ERROR mismatched types
- let y: f32 = 1f64; //~ ERROR mismatched types
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/float-literal-inference-restrictions.rs:2:18
- |
-LL | let x: f32 = 1;
- | --- ^
- | | |
- | | expected `f32`, found integer
- | | help: use a float literal: `1.0`
- | expected due to this
-
-error[E0308]: mismatched types
- --> $DIR/float-literal-inference-restrictions.rs:3:18
- |
-LL | let y: f32 = 1f64;
- | --- ^^^^ expected `f32`, found `f64`
- | |
- | expected due to this
- |
-help: change the type of the numeric literal from `f64` to `f32`
- |
-LL | let y: f32 = 1f32;
- | ~~~
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
| ^^^ the trait `UpperHex` is not implemented for `str`
|
= note: required because of the requirements on the impl of `UpperHex` for `&str`
-note: required by `std::fmt::UpperHex::fmt`
- --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
- |
-LL | fn fmt(&self, f: &mut Formatter<'_>) -> Result;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
--- /dev/null
+// run-pass
+
+fn ho<F>(f: F) -> isize where F: FnOnce(isize) -> isize { let n: isize = f(3); return n; }
+
+fn direct(x: isize) -> isize { return x + 1; }
+
+pub fn main() {
+ let a: isize = direct(3); // direct
+ let b: isize = ho(direct); // indirect unbound
+
+ assert_eq!(a, b);
+}
--- /dev/null
+struct Foo {
+ t: String
+}
+
+fn cond() -> bool { true }
+
+fn foo<F>(_: F) where F: FnOnce() {}
+
+fn main() {
+ let pth = break; //~ ERROR: `break` outside of a loop
+ if cond() { continue } //~ ERROR: `continue` outside of a loop
+
+ while cond() {
+ if cond() { break }
+ if cond() { continue }
+ foo(|| {
+ if cond() { break } //~ ERROR: `break` inside of a closure
+ if cond() { continue } //~ ERROR: `continue` inside of a closure
+ })
+ }
+
+ let rs: Foo = Foo{t: pth};
+
+ let unconstrained = break; //~ ERROR: `break` outside of a loop
+
+ // This used to ICE because `target_id` passed to `check_expr_break` would be the closure and
+ // not the `loop`, which failed in the call to `find_breakable`. (#65383)
+ 'lab: loop {
+ || {
+ break 'lab;
+ //~^ ERROR use of unreachable label `'lab`
+ //~| ERROR `break` inside of a closure
+ };
+ }
+}
--- /dev/null
+error[E0767]: use of unreachable label `'lab`
+ --> $DIR/break-outside-loop.rs:30:19
+ |
+LL | 'lab: loop {
+ | ---- unreachable label defined here
+LL | || {
+LL | break 'lab;
+ | ^^^^ unreachable label `'lab`
+ |
+ = note: labels are unreachable through functions, closures, async blocks and modules
+
+error[E0268]: `break` outside of a loop
+ --> $DIR/break-outside-loop.rs:10:15
+ |
+LL | let pth = break;
+ | ^^^^^ cannot `break` outside of a loop
+
+error[E0268]: `continue` outside of a loop
+ --> $DIR/break-outside-loop.rs:11:17
+ |
+LL | if cond() { continue }
+ | ^^^^^^^^ cannot `continue` outside of a loop
+
+error[E0267]: `break` inside of a closure
+ --> $DIR/break-outside-loop.rs:17:25
+ |
+LL | foo(|| {
+ | -- enclosing closure
+LL | if cond() { break }
+ | ^^^^^ cannot `break` inside of a closure
+
+error[E0267]: `continue` inside of a closure
+ --> $DIR/break-outside-loop.rs:18:25
+ |
+LL | foo(|| {
+ | -- enclosing closure
+LL | if cond() { break }
+LL | if cond() { continue }
+ | ^^^^^^^^ cannot `continue` inside of a closure
+
+error[E0268]: `break` outside of a loop
+ --> $DIR/break-outside-loop.rs:24:25
+ |
+LL | let unconstrained = break;
+ | ^^^^^ cannot `break` outside of a loop
+
+error[E0267]: `break` inside of a closure
+ --> $DIR/break-outside-loop.rs:30:13
+ |
+LL | || {
+ | -- enclosing closure
+LL | break 'lab;
+ | ^^^^^^^^^^ cannot `break` inside of a closure
+
+error: aborting due to 7 previous errors
+
+Some errors have detailed explanations: E0267, E0268, E0767.
+For more information about an error, try `rustc --explain E0267`.
--- /dev/null
+#![feature(never_type)]
+
+fn main() {
+ // The `if false` expressions are simply to
+ // make sure we don't avoid checking everything
+ // simply because a few expressions are unreachable.
+
+ if false {
+ let _: ! = { //~ ERROR mismatched types
+ 'a: while break 'a {};
+ };
+ }
+
+ if false {
+ let _: ! = {
+ while false { //~ ERROR mismatched types
+ break
+ }
+ };
+ }
+
+ if false {
+ let _: ! = {
+ while false { //~ ERROR mismatched types
+ return
+ }
+ };
+ }
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/break-while-condition.rs:9:20
+ |
+LL | let _: ! = {
+ | ____________________^
+LL | | 'a: while break 'a {};
+LL | | };
+ | |_________^ expected `!`, found `()`
+ |
+ = note: expected type `!`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/break-while-condition.rs:16:13
+ |
+LL | / while false {
+LL | | break
+LL | | }
+ | |_____________^ expected `!`, found `()`
+ |
+ = note: expected type `!`
+ found unit type `()`
+
+error[E0308]: mismatched types
+ --> $DIR/break-while-condition.rs:24:13
+ |
+LL | / while false {
+LL | | return
+LL | | }
+ | |_____________^ expected `!`, found `()`
+ |
+ = note: expected type `!`
+ found unit type `()`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
//~| NOTE `&str` is not an iterator
//~| HELP the trait `Iterator` is not implemented for `&str`
//~| NOTE required because of the requirements on the impl of `IntoIterator` for `&str`
- //~| NOTE required by `into_iter`
- //~| NOTE in this expansion of desugaring of `for` loop
//~| NOTE in this expansion of desugaring of `for` loop
//~| NOTE in this expansion of desugaring of `for` loop
//~| NOTE in this expansion of desugaring of `for` loop
|
= help: the trait `Iterator` is not implemented for `&str`
= note: required because of the requirements on the impl of `IntoIterator` for `&str`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
|
= help: the trait `Iterator` is not implemented for `MyStruct`
= note: required because of the requirements on the impl of `IntoIterator` for `MyStruct`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error[E0282]: type annotations needed
- --> $DIR/for-loop-unconstrained-element-type.rs:8:14
+ --> $DIR/for-loop-unconstrained-element-type.rs:8:9
|
LL | for i in Vec::new() { }
- | ^^^^^^^^^^ the element type for this iterator is not specified
+ | ^ ---------- the element type for this iterator is not specified
+ | |
+ | cannot infer type
error: aborting due to previous error
--> $DIR/fully-qualified-type-name1.rs:5:9
|
LL | x = 5;
- | ^
- | |
- | expected enum `Option`, found integer
- | help: try using a variant of the expected enum: `Some(5)`
+ | ^ expected enum `Option`, found integer
|
= note: expected enum `Option<usize>`
found type `{integer}`
+help: try wrapping the expression in `Some`
+ |
+LL | x = Some(5);
+ | +++++ +
error: aborting due to previous error
LL | fn bar(x: usize) -> Option<usize> {
| ------------- expected `Option<usize>` because of return type
LL | return x;
- | ^
- | |
- | expected enum `Option`, found `usize`
- | help: try using a variant of the expected enum: `Some(x)`
+ | ^ expected enum `Option`, found `usize`
|
= note: expected enum `Option<usize>`
found type `usize`
+help: try wrapping the expression in `Some`
+ |
+LL | return Some(x);
+ | +++++ +
error: aborting due to previous error
+++ /dev/null
-// run-pass
-
-fn ho<F>(f: F) -> isize where F: FnOnce(isize) -> isize { let n: isize = f(3); return n; }
-
-fn direct(x: isize) -> isize { return x + 1; }
-
-pub fn main() {
- let a: isize = direct(3); // direct
- let b: isize = ho(direct); // indirect unbound
-
- assert_eq!(a, b);
-}
= help: the trait `Iterator` is not implemented for `{integer}`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `{integer}`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
| +++++++++++++++++++
error[E0277]: the trait bound `T: Copy` is not satisfied
- --> $DIR/impl_bounds.rs:22:5
+ --> $DIR/impl_bounds.rs:22:24
|
LL | fn d() where Self: Copy {}
- | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T`
+ | ^^^^ the trait `Copy` is not implemented for `T`
|
note: required because of the requirements on the impl of `Copy` for `Fooy<T>`
--> $DIR/impl_bounds.rs:11:10
... |
LL | |
LL | | }
- | |_^ ...so that the type `T` will meet its required lifetime bounds...
+ | |_^
|
+ = note: ...so that the type `T` will meet its required lifetime bounds...
note: ...that is required by this bound
--> $DIR/issue-86483.rs:7:16
|
}
impl<T: X<Y<i32> = i32>> M for T {}
+//~^ NOTE the following trait bounds were not satisfied
struct S;
//~^ NOTE method `f` not found for this
a.f();
//~^ ERROR the method `f` exists for struct `S`, but its trait bounds were not satisfied
//~| NOTE method cannot be called on `S` due to unsatisfied trait bounds
- //~| NOTE the following trait bounds were not satisfied:
}
fn main() {}
error[E0599]: the method `f` exists for struct `S`, but its trait bounds were not satisfied
- --> $DIR/method-unsatified-assoc-type-predicate.rs:26:7
+ --> $DIR/method-unsatified-assoc-type-predicate.rs:27:7
|
LL | struct S;
| ---------
LL | a.f();
| ^ method cannot be called on `S` due to unsatisfied trait bounds
|
- = note: the following trait bounds were not satisfied:
- `<S as X>::Y<i32> = i32`
- which is required by `S: M`
+note: the following trait bounds were not satisfied because of the requirements of the implementation of `M` for `_`:
+ `<S as X>::Y<i32> = i32`
+ --> $DIR/method-unsatified-assoc-type-predicate.rs:14:26
+ |
+LL | impl<T: X<Y<i32> = i32>> M for T {}
+ | ^ ^
error: aborting due to previous error
#![allow(incomplete_features)]
#![feature(exclusive_range_pattern)]
#![feature(half_open_range_patterns)]
-#![feature(inline_const)]
+#![feature(inline_const_pat)]
fn main() {
let mut if_lettable = vec![];
y @ (0..5 | 6) => or_two.push(y),
//~^ exclusive range pattern syntax is experimental
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
- //~^ inline-const is experimental
+ //~^ inline-const in pattern position is experimental
//~| exclusive range pattern syntax is experimental
y @ -5.. => range_from.push(y),
y @ ..-7 => assert_eq!(y, -8),
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
-error[E0658]: inline-const is experimental
+error[E0658]: inline-const in pattern position is experimental
--> $DIR/range_pat_interactions3.rs:14:20
|
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
| ^^^^^
|
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
- = help: add `#![feature(inline_const)]` to the crate attributes to enable
+ = help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
error[E0658]: exclusive range pattern syntax is experimental
--> $DIR/range_pat_interactions3.rs:10:17
LL | let filter = map.filterx(|x: &_| true);
| ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` due to unsatisfied trait bounds
|
- = note: the following trait bounds were not satisfied:
- `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
- which is required by `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
- `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
- which is required by `&Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
- `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
- which is required by `&mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
+note: the following trait bounds were not satisfied because of the requirements of the implementation of `StreamExt` for `_`:
+ `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
+ `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
+ `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
+ --> $DIR/issue-30786.rs:106:9
+ |
+LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
+ | ^^^^^^^^^ ^
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`, but its trait bounds were not satisfied
--> $DIR/issue-30786.rs:141:24
LL | let count = filter.countx();
| ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` due to unsatisfied trait bounds
|
- = note: the following trait bounds were not satisfied:
- `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
- which is required by `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
- `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
- which is required by `&Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
- `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
- which is required by `&mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
+note: the following trait bounds were not satisfied because of the requirements of the implementation of `StreamExt` for `_`:
+ `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
+ `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
+ `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
+ --> $DIR/issue-30786.rs:106:9
+ |
+LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
+ | ^^^^^^^^^ ^
error: aborting due to 2 previous errors
LL | let filter = map.filterx(|x: &_| true);
| ^^^^^^^ method cannot be called on `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>` due to unsatisfied trait bounds
|
- = note: the following trait bounds were not satisfied:
- `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
- which is required by `Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
- `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
- which is required by `&Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
- `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
- which is required by `&mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: StreamExt`
+note: the following trait bounds were not satisfied because of the requirements of the implementation of `StreamExt` for `_`:
+ `&'a mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
+ `&'a mut &Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
+ `&'a mut &mut Map<Repeat, [closure@$DIR/issue-30786.rs:127:27: 127:36]>: Stream`
+ --> $DIR/issue-30786.rs:106:9
+ |
+LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
+ | ^^^^^^^^^ ^
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>`, but its trait bounds were not satisfied
--> $DIR/issue-30786.rs:141:24
LL | let count = filter.countx();
| ^^^^^^ method cannot be called on `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>` due to unsatisfied trait bounds
|
- = note: the following trait bounds were not satisfied:
- `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
- which is required by `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
- `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
- which is required by `&Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
- `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
- which is required by `&mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: StreamExt`
+note: the following trait bounds were not satisfied because of the requirements of the implementation of `StreamExt` for `_`:
+ `&'a mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
+ `&'a mut &Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
+ `&'a mut &mut Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:140:30: 140:42]>: Stream`
+ --> $DIR/issue-30786.rs:106:9
+ |
+LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
+ | ^^^^^^^^^ ^
error: aborting due to 2 previous errors
--> $DIR/issue-62203-hrtb-ice.rs:38:19
|
LL | let v = Unit2.m(
- | ^ expected struct `Unit4`, found associated type
+ | ^ expected associated type, found struct `Unit4`
|
- = note: expected struct `Unit4`
- found associated type `<_ as Ty<'_>>::V`
- = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4`
+ = note: expected associated type `<_ as Ty<'_>>::V`
+ found struct `Unit4`
+ = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` or calling a method that returns `<_ as Ty<'_>>::V`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+note: required by a bound in `T1::m`
+ --> $DIR/issue-62203-hrtb-ice.rs:27:51
+ |
+LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1
+ | - required by a bound in this
+LL | where
+LL | F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
+ | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m`
error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39] as FnOnce<((&'r u8,),)>>::Output == Unit3`
--> $DIR/issue-62203-hrtb-ice.rs:40:9
LL | |
LL | | f : |x| { drop(x); Unit4 }
LL | | });
- | |_________^ expected struct `Unit4`, found struct `Unit3`
+ | |_________^ expected struct `Unit3`, found struct `Unit4`
|
note: required because of the requirements on the impl of `for<'r> T0<'r, (&'r u8,)>` for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:17: 42:39]>`
--> $DIR/issue-62203-hrtb-ice.rs:17:16
|
LL | impl<'a, A, T> T0<'a, A> for L<T>
| ^^^^^^^^^ ^^^^
+note: required by a bound in `T1::m`
+ --> $DIR/issue-62203-hrtb-ice.rs:27:12
+ |
+LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1
+ | - required by a bound in this
+LL | where
+LL | F: for<'r> T0<'r, (<Self as Ty<'r>>::V,), O = <B as Ty<'r>>::V>,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m`
error: aborting due to 2 previous errors
--- /dev/null
+// run-pass
+#![no_std]
+
+extern crate std;
+
+std::thread_local!(static A: usize = 30);
+
+fn main() {
+}
+++ /dev/null
-// run-pass
-
-#![allow(non_shorthand_field_patterns)]
-#![allow(dead_code)]
-#![allow(unused_variables)]
-
-struct Foo(isize, isize, isize, isize);
-struct Bar{a: isize, b: isize, c: isize, d: isize}
-
-pub fn main() {
- let Foo(..) = Foo(5, 5, 5, 5);
- let Foo(..) = Foo(5, 5, 5, 5);
- let Bar{..} = Bar{a: 5, b: 5, c: 5, d: 5};
- let (..) = (5, 5, 5, 5);
- let Foo(a, b, ..) = Foo(5, 5, 5, 5);
- let Foo(.., d) = Foo(5, 5, 5, 5);
- let (a, b, ..) = (5, 5, 5, 5);
- let (.., c, d) = (5, 5, 5, 5);
- let Bar{b: b, ..} = Bar{a: 5, b: 5, c: 5, d: 5};
- match [5, 5, 5, 5] {
- [..] => { }
- }
- match [5, 5, 5, 5] {
- [a, ..] => { }
- }
- match [5, 5, 5, 5] {
- [.., b] => { }
- }
- match [5, 5, 5, 5] {
- [a, .., b] => { }
- }
- match [5, 5, 5] {
- [..] => { }
- }
- match [5, 5, 5] {
- [a, ..] => { }
- }
- match [5, 5, 5] {
- [.., a] => { }
- }
- match [5, 5, 5] {
- [a, .., b] => { }
- }
-}
+++ /dev/null
-fn f(y: Box<isize>) {
- *y = 5; //~ ERROR cannot assign
-}
-
-fn g() {
- let _frob = |q: Box<isize>| { *q = 2; }; //~ ERROR cannot assign
-}
-
-fn main() {}
+++ /dev/null
-error[E0594]: cannot assign to `*y`, as `y` is not declared as mutable
- --> $DIR/immut-function-arguments.rs:2:5
- |
-LL | fn f(y: Box<isize>) {
- | - help: consider changing this to be mutable: `mut y`
-LL | *y = 5;
- | ^^^^^^ cannot assign
-
-error[E0594]: cannot assign to `*q`, as `q` is not declared as mutable
- --> $DIR/immut-function-arguments.rs:6:35
- |
-LL | let _frob = |q: Box<isize>| { *q = 2; };
- | - ^^^^^^ cannot assign
- | |
- | help: consider changing this to be mutable: `mut q`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0594`.
+++ /dev/null
-// run-pass
-// aux-build:impl_privacy_xc_2.rs
-
-extern crate impl_privacy_xc_2;
-
-pub fn main() {
- let fish1 = impl_privacy_xc_2::Fish { x: 1 };
- let fish2 = impl_privacy_xc_2::Fish { x: 2 };
- if fish1.eq(&fish2) { println!("yes") } else { println!("no") };
-}
error[E0276]: impl has stricter requirements than trait
- --> $DIR/issue-55872-1.rs:12:5
+ --> $DIR/issue-55872-1.rs:12:15
|
LL | fn foo<T>() -> Self::E;
| ----------------------- definition of `foo` from trait
...
LL | fn foo<T: Default>() -> Self::E {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Default`
+ | ^^^^^^^ impl has extra requirement `T: Default`
error[E0277]: the trait bound `S: Copy` is not satisfied in `(S, T)`
--> $DIR/issue-55872-1.rs:12:29
LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
| ------------------------------- the found opaque type
|
- = note: expected opaque type `impl Future` (opaque type at <$DIR/issue-78722.rs:5:10>)
- found opaque type `impl Future` (opaque type at <$SRC_DIR/core/src/future/mod.rs:LL:COL>)
+ = note: expected opaque type `impl Future<Output = u8>`
+ found opaque type `impl Future`
= note: distinct uses of `impl Trait` result in different opaque types
error: aborting due to previous error
--- /dev/null
+#![allow(unused_imports)]
+
+mod foo {}
+
+use foo::{
+ ::bar, //~ ERROR crate root in paths can only be used in start position
+ super::bar, //~ ERROR `super` in paths can only be used in start position
+ self::bar, //~ ERROR `self` in paths can only be used in start position
+};
+
+fn main() {}
--- /dev/null
+error[E0433]: failed to resolve: crate root in paths can only be used in start position
+ --> $DIR/absolute-paths-in-nested-use-groups.rs:6:5
+ |
+LL | ::bar,
+ | ^ crate root in paths can only be used in start position
+
+error[E0433]: failed to resolve: `super` in paths can only be used in start position
+ --> $DIR/absolute-paths-in-nested-use-groups.rs:7:5
+ |
+LL | super::bar,
+ | ^^^^^ `super` in paths can only be used in start position
+
+error[E0433]: failed to resolve: `self` in paths can only be used in start position
+ --> $DIR/absolute-paths-in-nested-use-groups.rs:8:5
+ |
+LL | self::bar,
+ | ^^^^ `self` in paths can only be used in start position
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0433`.
--- /dev/null
+// run-pass
+// pretty-expanded FIXME #23616
+
+mod a {
+ pub fn f() {}
+ pub fn g() {}
+}
+
+mod b {
+ pub use a::*;
+}
+
+pub fn main() {
+ b::f();
+ b::g();
+}
#![feature(staged_api)]
+#![feature(arbitrary_self_types)]
#![stable(feature = "ipu_iterator", since = "1.0.0")]
fn ipu_flatten(&self) -> u32 {
0
}
+
+ #[unstable(feature = "ipu_flatten", issue = "99999")]
+ fn ipu_by_value_vs_by_ref(self) -> u32 where Self: Sized {
+ 0
+ }
+
+ #[unstable(feature = "ipu_flatten", issue = "99999")]
+ fn ipu_by_ref_vs_by_ref_mut(&self) -> u32 {
+ 0
+ }
+
+ #[unstable(feature = "ipu_flatten", issue = "99999")]
+ fn ipu_by_mut_ptr_vs_by_const_ptr(self: *mut Self) -> u32 {
+ 0
+ }
+
#[unstable(feature = "assoc_const_ipu_iter", issue = "99999")]
const C: i32;
}
+#![feature(arbitrary_self_types)]
+
pub trait IpuItertools {
fn ipu_flatten(&self) -> u32 {
1
}
+ fn ipu_by_value_vs_by_ref(&self) -> u32 {
+ 1
+ }
+
+ fn ipu_by_ref_vs_by_ref_mut(&mut self) -> u32 {
+ 1
+ }
+
+ fn ipu_by_mut_ptr_vs_by_const_ptr(self: *const Self) -> u32 {
+ 1
+ }
+
const C: i32;
}
fn main() {
assert_eq!('x'.ipu_flatten(), 1);
//~^ WARN an associated function with this name may be added to the standard library in the future
+//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
+ assert_eq!('x'.ipu_by_value_vs_by_ref(), 1);
+//~^ WARN an associated function with this name may be added to the standard library in the future
+//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
+ assert_eq!('x'.ipu_by_ref_vs_by_ref_mut(), 1);
+//~^ WARN an associated function with this name may be added to the standard library in the future
+//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
+ assert_eq!((&mut 'x' as *mut char).ipu_by_mut_ptr_vs_by_const_ptr(), 1);
+//~^ WARN an associated function with this name may be added to the standard library in the future
//~| WARN once this associated item is added to the standard library, the ambiguity may cause an
assert_eq!(char::C, 1);
//~^ WARN an associated constant with this name may be added to the standard library in the future
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method
= help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten`
+warning: an associated function with this name may be added to the standard library in the future
+ --> $DIR/inference_unstable.rs:19:20
+ |
+LL | assert_eq!('x'.ipu_by_value_vs_by_ref(), 1);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
+ = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
+ = help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_by_value_vs_by_ref(...)` to keep using the current method
+ = help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_by_value_vs_by_ref`
+
+warning: an associated function with this name may be added to the standard library in the future
+ --> $DIR/inference_unstable.rs:22:20
+ |
+LL | assert_eq!('x'.ipu_by_ref_vs_by_ref_mut(), 1);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
+ = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
+ = help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_by_ref_vs_by_ref_mut(...)` to keep using the current method
+ = help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_by_ref_vs_by_ref_mut`
+
+warning: an associated function with this name may be added to the standard library in the future
+ --> $DIR/inference_unstable.rs:25:40
+ |
+LL | assert_eq!((&mut 'x' as *mut char).ipu_by_mut_ptr_vs_by_const_ptr(), 1);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
+ = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
+ = help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_by_mut_ptr_vs_by_const_ptr(...)` to keep using the current method
+ = help: add `#![feature(ipu_flatten)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_by_mut_ptr_vs_by_const_ptr`
+
warning: an associated constant with this name may be added to the standard library in the future
- --> $DIR/inference_unstable.rs:19:16
+ --> $DIR/inference_unstable.rs:28:16
|
LL | assert_eq!(char::C, 1);
| ^^^^^^^ help: use the fully qualified path to the associated const: `<char as IpuItertools>::C`
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
= help: add `#![feature(assoc_const_ipu_iter)]` to the crate attributes to enable `inference_unstable_iterator::IpuIterator::C`
-warning: 2 warnings emitted
+warning: 5 warnings emitted
- impl Borrow<str> for String;
- impl<T> Borrow<T> for T
where T: ?Sized;
+note: required by a bound in `HashMap::<K, V, S>::get`
+ --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
+ |
+LL | K: Borrow<Q>,
+ | ^^^^^^^^^ required by this bound in `HashMap::<K, V, S>::get`
+help: consider specifying the type argument in the function call
+ |
+LL | .get::<Q>(&"key".into())
+ | +++++
error: aborting due to previous error
--- /dev/null
+// run-pass
+
+#![allow(dead_code)]
+// Test that the lambda kind is inferred correctly as a return
+// expression
+
+// pretty-expanded FIXME #23616
+
+fn unique() -> Box<dyn FnMut()+'static> { return Box::new(|| ()); }
+
+pub fn main() {
+}
--- /dev/null
+// run-pass
+
+#![allow(dead_code)]
+// Test that the lambda kind is inferred correctly as a return
+// expression
+
+// pretty-expanded FIXME #23616
+
+fn unique() -> Box<dyn FnMut()+'static> { Box::new(|| ()) }
+
+pub fn main() {
+}
--- /dev/null
+// run-pass
+
+#![allow(unused_must_use)]
+// Make sure the type inference for the new range expression work as
+// good as the old one. Check out issue #21672, #21595 and #21649 for
+// more details.
+
+
+fn main() {
+ let xs = (0..8).map(|i| i == 1u64).collect::<Vec<_>>();
+ assert_eq!(xs[1], true);
+ let xs = (0..8).map(|i| 1u64 == i).collect::<Vec<_>>();
+ assert_eq!(xs[1], true);
+ let xs: Vec<u8> = (0..10).collect();
+ assert_eq!(xs.len(), 10);
+
+ for x in 0..10 { x % 2; }
+ for x in 0..100 { x as f32; }
+
+ let array = [true, false];
+ for i in 0..1 { array[i]; }
+}
--- /dev/null
+fn main() {
+ let x = 3;
+ let y: i32 = 3;
+
+ fn identity_u8(n: u8) -> u8 { n }
+ fn identity_u16(n: u16) -> u16 { n }
+
+ identity_u8(x); // after this, `x` is assumed to have type `u8`
+ identity_u16(x);
+ //~^ ERROR mismatched types
+ //~| expected `u16`, found `u8`
+ identity_u16(y);
+ //~^ ERROR mismatched types
+ //~| expected `u16`, found `i32`
+
+ let a = 3;
+
+ fn identity_i(n: isize) -> isize { n }
+
+ identity_i(a); // ok
+ identity_u16(a);
+ //~^ ERROR mismatched types
+ //~| expected `u16`, found `isize`
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/tutorial-suffix-inference-test.rs:9:18
+ |
+LL | identity_u16(x);
+ | ^ expected `u16`, found `u8`
+ |
+help: you can convert a `u8` to a `u16`
+ |
+LL | identity_u16(x.into());
+ | +++++++
+
+error[E0308]: mismatched types
+ --> $DIR/tutorial-suffix-inference-test.rs:12:18
+ |
+LL | identity_u16(y);
+ | ^ expected `u16`, found `i32`
+ |
+help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit
+ |
+LL | identity_u16(y.try_into().unwrap());
+ | ++++++++++++++++++++
+
+error[E0308]: mismatched types
+ --> $DIR/tutorial-suffix-inference-test.rs:21:18
+ |
+LL | identity_u16(a);
+ | ^ expected `u16`, found `isize`
+ |
+help: you can convert an `isize` to a `u16` and panic if the converted value doesn't fit
+ |
+LL | identity_u16(a.try_into().unwrap());
+ | ++++++++++++++++++++
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// run-pass
+
+#![allow(non_upper_case_globals)]
+#![allow(dead_code)]
+#![allow(unused_assignments)]
+#![allow(unused_variables)]
+// Test a scenario where we generate a constraint like `?1 <: &?2`.
+// In such a case, it is important that we instantiate `?1` with `&?3`
+// where `?3 <: ?2`, and not with `&?2`. This is a regression test for
+// #18653. The important thing is that we build.
+
+use std::cell::RefCell;
+
+enum Wrap<A> {
+ WrapSome(A),
+ WrapNone
+}
+
+use Wrap::*;
+
+struct T;
+struct U;
+
+trait Get<T: ?Sized> {
+ fn get(&self) -> &T;
+}
+
+impl Get<dyn MyShow + 'static> for Wrap<T> {
+ fn get(&self) -> &(dyn MyShow + 'static) {
+ static x: usize = 42;
+ &x
+ }
+}
+
+impl Get<usize> for Wrap<U> {
+ fn get(&self) -> &usize {
+ static x: usize = 55;
+ &x
+ }
+}
+
+trait MyShow { fn dummy(&self) { } }
+impl<'a> MyShow for &'a (dyn MyShow + 'a) { }
+impl MyShow for usize { }
+fn constrain<'a>(rc: RefCell<&'a (dyn MyShow + 'a)>) { }
+
+fn main() {
+ let mut collection: Wrap<_> = WrapNone;
+
+ {
+ let __arg0 = Get::get(&collection);
+ let __args_cell = RefCell::new(__arg0);
+ constrain(__args_cell);
+ }
+ collection = WrapSome(T);
+}
+++ /dev/null
-// compile-flags: -O
-// run-pass
-
-#![allow(unused_must_use)]
-// Makes sure that zero-initializing large types is reasonably fast,
-// Doing it incorrectly causes massive slowdown in LLVM during
-// optimisation.
-
-// pretty-expanded FIXME #23616
-// ignore-emscripten no threads support
-
-#![feature(intrinsics)]
-
-use std::{mem, thread};
-
-const SIZE: usize = 1024 * 1024;
-
-fn main() {
- // do the test in a new thread to avoid (spurious?) stack overflows
- thread::spawn(|| {
- let _memory: [u8; SIZE] = unsafe { mem::zeroed() };
- }).join();
-}
// build-pass
-#![allow(incomplete_features)]
#![feature(inline_const)]
use std::cell::Cell;
// run-pass
-#![allow(incomplete_features)]
#![feature(inline_const)]
+
fn foo() -> i32 {
const {
let x = 5 + 10;
// check-pass
#![feature(inline_const)]
-#![allow(incomplete_features)]
pub fn todo<T>() -> T {
const { todo!() }
-#![allow(incomplete_features)]
#![feature(const_mut_refs)]
#![feature(inline_const)]
error[E0597]: `y` does not live long enough
- --> $DIR/const-expr-lifetime-err.rs:24:30
+ --> $DIR/const-expr-lifetime-err.rs:23:30
|
LL | fn foo<'a>() {
| -- lifetime `'a` defined here
// run-pass
-#![allow(incomplete_features)]
#![feature(const_mut_refs)]
#![feature(inline_const)]
// run-pass
-#![allow(incomplete_features)]
#![feature(inline_const)]
+
macro_rules! do_const_block{
($val:block) => { const $val }
}
// run-pass
-#![allow(incomplete_features)]
#![feature(inline_const)]
const fn bar() -> i32 {
#![allow(incomplete_features)]
-#![feature(inline_const)]
+#![feature(inline_const_pat)]
// rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter
// check-pass
-#![feature(inline_const)]
+#![feature(inline_const_pat)]
#![allow(incomplete_features)]
fn main() {
#![allow(incomplete_features)]
#![feature(const_mut_refs)]
-#![feature(inline_const)]
+#![feature(inline_const_pat)]
use std::marker::PhantomData;
#![allow(incomplete_features)]
#![feature(const_mut_refs)]
#![feature(inline_const)]
+#![feature(inline_const_pat)]
use std::marker::PhantomData;
// build-pass
#![allow(incomplete_features)]
-#![feature(inline_const, half_open_range_patterns, exclusive_range_pattern)]
+#![feature(inline_const_pat, half_open_range_patterns, exclusive_range_pattern)]
fn main() {
const N: u32 = 10;
let x: u32 = 3;
// run-pass
#![allow(incomplete_features)]
-#![feature(inline_const)]
+#![feature(inline_const_pat)]
const MMIO_BIT1: u8 = 4;
const MMIO_BIT2: u8 = 5;
+++ /dev/null
-// build-pass
-// compile-flags:-Copt-level=0
-// edition:2018
-
-struct S<T>(std::marker::PhantomData<T>);
-
-impl<T> std::ops::Deref for S<T> {
- type Target = T;
-
- fn deref(&self) -> &Self::Target {
- todo!()
- }
-}
-impl<T> std::ops::DerefMut for S<T> {
- fn deref_mut(&mut self) -> &mut Self::Target {
- todo!()
- }
-}
-
-async fn new() -> S<u64> {
- todo!()
-}
-
-async fn crash() {
- *new().await = 1 + 1;
-}
-
-fn main() {
- let _ = crash();
-}
+++ /dev/null
-#[derive(Clone)]
-pub struct Struct<A>(A);
-
-impl<A> Struct<A> {
- pub fn new() -> Self {
- todo!()
- }
-}
error[E0276]: impl has stricter requirements than trait
- --> $DIR/issue-14853.rs:12:5
+ --> $DIR/issue-14853.rs:12:15
|
LL | fn yay<T: Debug>(_: Option<Self>, thing: &[T]);
| ----------------------------------------------- definition of `yay` from trait
...
LL | fn yay<T: Str>(_:Option<X>, thing: &[T]) {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Str`
+ | ^^^ impl has extra requirement `T: Str`
error: aborting due to previous error
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `[{integer}]`
-note: required by `Box::<T>::new`
+note: required by a bound in `Box::<T>::new`
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
-LL | pub fn new(x: T) -> Self {
- | ^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<T> Box<T> {
+ | ^ required by this bound in `Box::<T>::new`
error: aborting due to previous error
|
LL | fn add_state(op: <isize as HasState>::State) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasState` is not implemented for `isize`
- |
-note: required by a bound in `HasState`
- --> $DIR/issue-18611.rs:5:1
- |
-LL | trait HasState {
- | ^^^^^^^^^^^^^^ required by this bound in `HasState`
error: aborting due to previous error
}
impl<'a> A<'a> for B {
- fn foo<F>(&mut self, f: F) //~ ERROR impl has stricter
- where F: fmt::Debug + 'static,
+ fn foo<F>(&mut self, f: F)
+ where F: fmt::Debug + 'static, //~ ERROR impl has stricter
{
self.list.push(Box::new(f));
}
error[E0276]: impl has stricter requirements than trait
- --> $DIR/issue-18937.rs:19:5
+ --> $DIR/issue-18937.rs:20:31
|
LL | / fn foo<F>(&mut self, f: F)
LL | | where F: fmt::Debug + 'a,
LL | | Self: Sized;
| |__________________________- definition of `foo` from trait
...
-LL | / fn foo<F>(&mut self, f: F)
-LL | | where F: fmt::Debug + 'static,
-LL | | {
-LL | | self.list.push(Box::new(f));
-LL | | }
- | |_____^ impl has extra requirement `F: 'static`
+LL | where F: fmt::Debug + 'static,
+ | ^^^^^^^ impl has extra requirement `F: 'static`
error: aborting due to previous error
|
LL | b.sort();
| ^^^^ the trait `Ord` is not implemented for `X`
+ |
+note: required by a bound in `slice::<impl [T]>::sort`
+ --> $SRC_DIR/alloc/src/slice.rs:LL:COL
+ |
+LL | T: Ord,
+ | ^^^ required by this bound in `slice::<impl [T]>::sort`
error: aborting due to previous error
-error[E0282]: type annotations needed for `&(_,)`
+error[E0282]: type annotations needed for `(_,)`
--> $DIR/issue-20261.rs:4:11
|
LL | for (ref i,) in [].iter() {
- | --------- the element type for this iterator is not specified
+ | --------- this method call resolves to `std::slice::Iter<'_, T>`
LL | i.clone();
| ^^^^^ cannot infer type
|
| ^^^ ^
= note: 127 redundant requirements hidden
= note: required because of the requirements on the impl of `Foo` for `NoData<T>`
-note: required by a bound in `Foo`
- --> $DIR/issue-20413.rs:1:1
- |
-LL | trait Foo {
- | ^^^^^^^^^ required by this bound in `Foo`
error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
--> $DIR/issue-20413.rs:8:36
| ^^^ ^
= note: 127 redundant requirements hidden
= note: required because of the requirements on the impl of `Foo` for `NoData<T>`
-note: required by a bound in `Foo`
- --> $DIR/issue-20413.rs:1:1
- |
-LL | trait Foo {
- | ^^^^^^^^^ required by this bound in `Foo`
error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz`
--> $DIR/issue-20413.rs:28:42
| ^^^ ^
= note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `Baz` for `EvenLessData<T>`
-note: required by a bound in `Baz`
- --> $DIR/issue-20413.rs:20:1
- |
-LL | trait Baz {
- | ^^^^^^^^^ required by this bound in `Baz`
error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Baz`
--> $DIR/issue-20413.rs:28:42
| ^^^ ^
= note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `Baz` for `EvenLessData<T>`
-note: required by a bound in `Baz`
- --> $DIR/issue-20413.rs:20:1
- |
-LL | trait Baz {
- | ^^^^^^^^^ required by this bound in `Baz`
error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar`
--> $DIR/issue-20413.rs:36:42
| ^^^ ^
= note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `Bar` for `AlmostNoData<T>`
-note: required by a bound in `Bar`
- --> $DIR/issue-20413.rs:16:1
- |
-LL | trait Bar {
- | ^^^^^^^^^ required by this bound in `Bar`
error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Bar`
--> $DIR/issue-20413.rs:36:42
| ^^^ ^
= note: 126 redundant requirements hidden
= note: required because of the requirements on the impl of `Bar` for `AlmostNoData<T>`
-note: required by a bound in `Bar`
- --> $DIR/issue-20413.rs:16:1
- |
-LL | trait Bar {
- | ^^^^^^^^^ required by this bound in `Bar`
error: aborting due to 7 previous errors
|
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
= note: required because of the requirements on the impl of `IntoIterator` for `dyn Iterator<Item = &'a mut u8>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider mutably borrowing here
|
LL | for item in &mut *things { *item = 0 }
LL | struct Foo(Bar);
| ^^^ the trait `Hash` is not implemented for `Bar`
|
-note: required by a bound in `std::hash::Hash::hash`
- --> $SRC_DIR/core/src/hash/mod.rs:LL:COL
- |
-LL | fn hash<H: Hasher>(&self, state: &mut H);
- | ^ required by this bound in `std::hash::Hash::hash`
= note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
| ^^^ cannot infer type for reference `&'a T`
|
= note: cannot satisfy `&'a T: Foo`
-note: required by a bound in `Foo`
- --> $DIR/issue-21974.rs:6:1
- |
-LL | trait Foo {
- | ^^^^^^^^^ required by this bound in `Foo`
error: aborting due to previous error
| required by a bound introduced by this call
|
= help: the trait `FnMut<(_, char)>` is not implemented for `()`
+note: required by a bound in `fold`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(B, Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `fold`
error: aborting due to previous error
| ^^^^^^^^^^^ cannot infer type for type parameter `T0`
|
= note: cannot satisfy `T0: Trait0<'l0>`
-note: required by a bound in `Trait0`
- --> $DIR/issue-24424.rs:2:1
- |
-LL | trait Trait0<'l0> {}
- | ^^^^^^^^^^^^^^^^^ required by this bound in `Trait0`
error: aborting due to previous error
| required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
-note: required by `std::iter::Iterator::next`
- --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- |
-LL | fn next(&mut self) -> Option<Self::Item>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `bool` is not an iterator
--> $DIR/issue-28098.rs:6:14
|
= help: the trait `Iterator` is not implemented for `bool`
= note: required because of the requirements on the impl of `IntoIterator` for `bool`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `()` is not an iterator
--> $DIR/issue-28098.rs:9:28
| required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
-note: required by `std::iter::Iterator::next`
- --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- |
-LL | fn next(&mut self) -> Option<Self::Item>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `()` is not an iterator
--> $DIR/issue-28098.rs:2:13
| required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
-note: required by `std::iter::Iterator::next`
- --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- |
-LL | fn next(&mut self) -> Option<Self::Item>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `()` is not an iterator
--> $DIR/issue-28098.rs:22:28
| required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
-note: required by `std::iter::Iterator::next`
- --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- |
-LL | fn next(&mut self) -> Option<Self::Item>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `bool` is not an iterator
--> $DIR/issue-28098.rs:25:14
|
= help: the trait `Iterator` is not implemented for `bool`
= note: required because of the requirements on the impl of `IntoIterator` for `bool`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `()` is not an iterator
--> $DIR/issue-28098.rs:18:13
| ^^^^^^^^^^^^^^^^^^^^
LL | impl Foo for S5<u64> { fn xxx(&self) {} }
| ^^^^^^^^^^^^^^^^^^^^
-note: required by `Foo::xxx`
- --> $DIR/issue-29147.rs:10:13
- |
-LL | trait Foo { fn xxx(&self); }
- | ^^^^^^^^^^^^^^
error: aborting due to previous error
})
.cloned()
//~^ ERROR type mismatch resolving
- //~| expected type `u8`
- //~| found reference `&_`
.collect(); //~ ERROR the method
}
--> $DIR/issue-31173.rs:10:10
|
LL | .cloned()
- | ^^^^^^ expected `u8`, found reference
+ | ^^^^^^ expected reference, found `u8`
|
- = note: expected type `u8`
- found reference `&_`
+ = note: expected reference `&_`
+ found type `u8`
+note: required by a bound in `cloned`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | Self: Sized + Iterator<Item = &'a T>,
+ | ^^^^^^^^^^^^ required by this bound in `cloned`
error[E0599]: the method `collect` exists for struct `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>`, but its trait bounds were not satisfied
- --> $DIR/issue-31173.rs:14:10
+ --> $DIR/issue-31173.rs:12:10
|
LL | .collect();
| ^^^^^^^ method cannot be called on `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, [closure@$DIR/issue-31173.rs:6:39: 9:6]>>` due to unsatisfied trait bounds
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= note: required because of the requirements on the impl of `FromResidual<Result<Infallible, {integer}>>` for `Result<i32, ()>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
fn main() {
for _ in HashMap::new().iter().cloned() {} //~ ERROR type mismatch
//~^ ERROR type mismatch
- //~| ERROR type mismatch
}
--> $DIR/issue-33941.rs:4:36
|
LL | for _ in HashMap::new().iter().cloned() {}
- | ^^^^^^ expected tuple, found reference
- |
- = note: expected tuple `(&_, &_)`
- found reference `&_`
-
-error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
- --> $DIR/issue-33941.rs:4:14
- |
-LL | for _ in HashMap::new().iter().cloned() {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found tuple
+ | ^^^^^^ expected reference, found tuple
|
= note: expected reference `&_`
found tuple `(&_, &_)`
- = note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
- = note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
+note: required by a bound in `cloned`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | Self: Sized + Iterator<Item = &'a T>,
+ | ^^^^^^^^^^^^ required by this bound in `cloned`
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
--> $DIR/issue-33941.rs:4:14
= note: expected reference `&_`
found tuple `(&_, &_)`
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
-note: required by `std::iter::Iterator::next`
- --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
- |
-LL | fn next(&mut self) -> Option<Self::Item>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0271`.
| in this derive macro expansion
|
= help: the trait `PartialOrd` is not implemented for `Comparable`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
| ^^^^^^^ value of type `Vec<(u32, _, _)>` cannot be built from `std::iter::Iterator<Item=()>`
|
= help: the trait `FromIterator<()>` is not implemented for `Vec<(u32, _, _)>`
+note: required by a bound in `collect`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
error: aborting due to 2 previous errors
+++ /dev/null
-use std::collections::HashSet;
-
-fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool {
- this.is_subset(other)
- //~^ ERROR the method
-}
-
-fn main() {}
+++ /dev/null
-error[E0599]: the method `is_subset` exists for reference `&HashSet<T>`, but its trait bounds were not satisfied
- --> $DIR/issue-35677.rs:4:10
- |
-LL | this.is_subset(other)
- | ^^^^^^^^^ method cannot be called on `&HashSet<T>` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `T: Eq`
- `T: Hash`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
|
LL | impl Visit for () where
| ^^^^^ ^^
-note: required by `Visit::visit`
- --> $DIR/issue-39970.rs:6:5
- |
-LL | fn visit() {}
- | ^^^^^^^^^^
error: aborting due to previous error
| --- ^^^^^^^ expected function that takes a single 0-tuple as argument
| |
| required by a bound introduced by this call
+ |
+note: required by a bound in `Option::<T>::map`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ |
+LL | pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
+ | ^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
error: aborting due to previous error
| --- ^^^^^^^^ expected function that takes 1 argument
| |
| required by a bound introduced by this call
+ |
+note: required by a bound in `Option::<T>::map`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+ |
+LL | pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
+ | ^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
--> $DIR/issue-47706.rs:27:9
LL - missing_discourses()?
LL + missing_discourses()
|
-help: try using a variant of the expected enum
+help: try wrapping the expression in `Ok`
|
LL | Ok(missing_discourses()?)
- |
+ | +++ +
error: aborting due to previous error
|
= note: expected struct `S`
found enum `Either<_, _>`
+help: you might have meant to use field `0` whose type is `Either<usize, usize>`
+ |
+LL | match S(Either::Left(5)).0 {
+ | ~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: Tt`
-note: required by a bound in `Tt::const_val`
- --> $DIR/issue-54954.rs:5:24
- |
-LL | const fn const_val<T: Sized>() -> usize {
- | ^ required by this bound in `Tt::const_val`
error: aborting due to 2 previous errors
|
= note: cannot satisfy `_: Foo`
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
-note: required by `Foo::SIZE`
- --> $DIR/issue-58022.rs:2:5
- |
-LL | const SIZE: usize;
- | ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
| ----------------------------------- ^^ the trait `_Func<_>` is not implemented for `()`
| |
| required by a bound introduced by this call
- |
-note: required by `_Func::func`
- --> $DIR/issue-66353.rs:4:5
- |
-LL | fn func(_: Self);
- | ^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
| ^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
|
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
+note: required by a bound in `collect`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
error[E0277]: a value of type `Vec<f64>` cannot be built from an iterator over elements of type `&f64`
--> $DIR/issue-66923-show-error-for-correct-call.rs:12:29
| ^^^^^^^ value of type `Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
|
= help: the trait `FromIterator<&f64>` is not implemented for `Vec<f64>`
+note: required by a bound in `collect`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
error: aborting due to 2 previous errors
...
LL | impl<T: Element<S>, S> Element<[S; 3]> for T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: required by a bound in `Foo::foo`
+ --> $DIR/issue-69683.rs:15:9
+ |
+LL | u8: Element<I>,
+ | ^^^^^^^^^^ required by this bound in `Foo::foo`
+LL | {
+LL | fn foo(self, x: <u8 as Element<I>>::Array);
+ | --- required by a bound in this
error: aborting due to 2 previous errors
+++ /dev/null
-// aux-build:issue-69725.rs
-
-extern crate issue_69725;
-use issue_69725::Struct;
-
-fn crash<A>() {
- let _ = Struct::<A>::new().clone();
- //~^ ERROR: the method
-}
-
-fn main() {}
+++ /dev/null
-error[E0599]: the method `clone` exists for struct `Struct<A>`, but its trait bounds were not satisfied
- --> $DIR/issue-69725.rs:7:32
- |
-LL | let _ = Struct::<A>::new().clone();
- | ^^^^^ method cannot be called on `Struct<A>` due to unsatisfied trait bounds
- |
- ::: $DIR/auxiliary/issue-69725.rs:2:1
- |
-LL | pub struct Struct<A>(A);
- | ------------------------ doesn't satisfy `Struct<A>: Clone`
- |
- = note: the following trait bounds were not satisfied:
- `A: Clone`
- which is required by `Struct<A>: Clone`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:7:22
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:12:26
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:22:22
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:29:22
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:38:22
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:47:22
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:54:22
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl<> From<&String> for String;
- impl<> From<&str> for String;
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:63:22
= help: the trait `Iterator` is not implemented for `{integer}`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `{integer}`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `u8` is not an iterator
--> $DIR/integral.rs:4:14
= help: the trait `Iterator` is not implemented for `u8`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `u8`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `i8` is not an iterator
--> $DIR/integral.rs:6:14
= help: the trait `Iterator` is not implemented for `i8`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `i8`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `u16` is not an iterator
--> $DIR/integral.rs:8:14
= help: the trait `Iterator` is not implemented for `u16`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `u16`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `i16` is not an iterator
--> $DIR/integral.rs:10:14
= help: the trait `Iterator` is not implemented for `i16`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `i16`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `u32` is not an iterator
--> $DIR/integral.rs:12:14
= help: the trait `Iterator` is not implemented for `u32`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `u32`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `i32` is not an iterator
--> $DIR/integral.rs:14:14
= help: the trait `Iterator` is not implemented for `i32`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `i32`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `u64` is not an iterator
--> $DIR/integral.rs:16:14
= help: the trait `Iterator` is not implemented for `u64`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `u64`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `i64` is not an iterator
--> $DIR/integral.rs:18:14
= help: the trait `Iterator` is not implemented for `i64`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `i64`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `usize` is not an iterator
--> $DIR/integral.rs:20:14
= help: the trait `Iterator` is not implemented for `usize`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `usize`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `isize` is not an iterator
--> $DIR/integral.rs:22:14
= help: the trait `Iterator` is not implemented for `isize`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `isize`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `{float}` is not an iterator
--> $DIR/integral.rs:24:14
|
= help: the trait `Iterator` is not implemented for `{float}`
= note: required because of the requirements on the impl of `IntoIterator` for `{float}`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors
= help: the trait `Iterator` is not implemented for `RangeTo<{integer}>`
= note: `..end` is a `RangeTo`, which cannot be iterated on; you might have meant to have a bounded `Range`: `0..end`
= note: required because of the requirements on the impl of `IntoIterator` for `RangeTo<{integer}>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `RangeToInclusive<{integer}>` is not an iterator
--> $DIR/ranges.rs:4:14
= help: the trait `Iterator` is not implemented for `RangeToInclusive<{integer}>`
= note: `..=end` is a `RangeToInclusive`, which cannot be iterated on; you might have meant to have a bounded `RangeInclusive`: `0..=end`
= note: required because of the requirements on the impl of `IntoIterator` for `RangeToInclusive<{integer}>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
|
= help: the trait `Iterator` is not implemented for `String`
= note: required because of the requirements on the impl of `IntoIterator` for `String`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: `&str` is not an iterator
--> $DIR/string.rs:4:14
|
= help: the trait `Iterator` is not implemented for `&str`
= note: required because of the requirements on the impl of `IntoIterator` for `&str`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
+++ /dev/null
-// run-pass
-
-#![allow(unused_must_use)]
-#![allow(dead_code)]
-use std::thread;
-
-fn user(_i: isize) {}
-
-fn foo() {
- // Here, i is *copied* into the proc (heap closure).
- // Requires allocation. The proc's copy is not mutable.
- let mut i = 0;
- let t = thread::spawn(move|| {
- user(i);
- println!("spawned {}", i)
- });
- i += 1;
- println!("original {}", i);
- t.join();
-}
-
-fn bar() {
- // Here, the original i has not been moved, only copied, so is still
- // mutable outside of the proc.
- let mut i = 0;
- while i < 10 {
- let t = thread::spawn(move|| {
- user(i);
- });
- i += 1;
- t.join();
- }
-}
-
-fn car() {
- // Here, i must be shadowed in the proc to be mutable.
- let mut i = 0;
- while i < 10 {
- let t = thread::spawn(move|| {
- let mut i = i;
- i += 1;
- user(i);
- });
- i += 1;
- t.join();
- }
-}
-
-pub fn main() {}
--- /dev/null
+// Regression test for #87573, ensures that duplicate lang items or invalid generics
+// for lang items doesn't cause ICE.
+
+#![feature(no_core, lang_items)]
+#![no_core]
+#![crate_type = "lib"]
+
+pub static STATIC_BOOL: bool = true;
+
+#[lang = "sized"]
+trait Sized {}
+
+#[lang = "copy"]
+trait Copy {}
+
+#[lang = "sync"]
+trait Sync {}
+impl Sync for bool {}
+
+#[lang = "drop_in_place"]
+//~^ ERROR: `drop_in_place` language item must be applied to a function with at least 1 generic argument
+fn drop_fn() {
+ while false {}
+}
+
+#[lang = "start"]
+//~^ ERROR: `start` language item must be applied to a function with 1 generic argument
+fn start(){}
--- /dev/null
+error[E0718]: `drop_in_place` language item must be applied to a function with at least 1 generic argument
+ --> $DIR/issue-87573.rs:20:1
+ |
+LL | #[lang = "drop_in_place"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | fn drop_fn() {
+ | - this function has 0 generic arguments
+
+error[E0718]: `start` language item must be applied to a function with 1 generic argument
+ --> $DIR/issue-87573.rs:26:1
+ |
+LL | #[lang = "start"]
+ | ^^^^^^^^^^^^^^^^^
+LL |
+LL | fn start(){}
+ | - this function has 0 generic arguments
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0718`.
error: layout_of(E) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 0..=0,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 4,
- },
- },
- Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 4,
- },
- Size {
- raw: 4,
- },
- Size {
- raw: 8,
- },
- ],
- memory_index: [
- 0,
- 1,
- 2,
- ],
- },
- variants: Single {
- index: 1,
- },
- abi: Uninhabited,
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 12,
- },
- },
- ],
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 0..=0,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 12,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 4,
+ },
+ },
+ Layout {
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 4,
+ },
+ Size {
+ raw: 4,
+ },
+ Size {
+ raw: 8,
+ },
+ ],
+ memory_index: [
+ 0,
+ 1,
+ 2,
+ ],
+ },
+ variants: Single {
+ index: 1,
+ },
+ abi: Uninhabited,
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 12,
+ },
+ },
+ ],
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 12,
+ },
+ }
--> $DIR/debug.rs:6:1
|
LL | enum E { Foo, Bar(!, i32, i32) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(S) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- Size {
- raw: 0,
- },
- Size {
- raw: 4,
- },
- ],
- memory_index: [
- 1,
- 0,
- 2,
- ],
- },
- variants: Single {
- index: 0,
- },
- abi: ScalarPair(
- Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 0..=4294967295,
- },
- Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 0..=4294967295,
- },
- ),
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 8,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ Size {
+ raw: 0,
+ },
+ Size {
+ raw: 4,
+ },
+ ],
+ memory_index: [
+ 1,
+ 0,
+ 2,
+ ],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: ScalarPair(
+ Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 0..=4294967295,
+ },
+ Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 0..=4294967295,
+ },
+ ),
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 8,
+ },
+ }
--> $DIR/debug.rs:9:1
|
LL | struct S { f1: i32, f2: (), f3: i32 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(U) = Layout {
- fields: Union(
- 2,
- ),
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 8,
- },
-}
+ fields: Union(
+ 2,
+ ),
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 8,
+ },
+ }
--> $DIR/debug.rs:12:1
|
LL | union U { f1: (i32, i32), f3: i32 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(std::result::Result<i32, i32>) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 0..=1,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 4,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 8,
- },
- },
- Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 4,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Single {
- index: 1,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 8,
- },
- },
- ],
- },
- abi: ScalarPair(
- Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 0..=1,
- },
- Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 0..=4294967295,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 0..=1,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 8,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 0..=1,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 4,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 8,
+ },
+ },
+ Layout {
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 4,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Single {
+ index: 1,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 8,
+ },
+ },
+ ],
+ },
+ abi: ScalarPair(
+ Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 0..=1,
+ },
+ Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 0..=4294967295,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 0..=1,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 8,
+ },
+ }
--> $DIR/debug.rs:15:1
|
LL | type Test = Result<i32, i32>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(i32) = Layout {
- fields: Primitive,
- variants: Single {
- index: 0,
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 0..=4294967295,
- },
- ),
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: $PREF_ALIGN,
- },
- size: Size {
- raw: 4,
- },
-}
+ fields: Primitive,
+ variants: Single {
+ index: 0,
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 0..=4294967295,
+ },
+ ),
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: $PREF_ALIGN,
+ },
+ size: Size {
+ raw: 4,
+ },
+ }
--> $DIR/debug.rs:18:1
|
LL | type T = impl std::fmt::Debug;
error: layout_of(A) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 0..=0,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 0,
- },
- },
- size: Size {
- raw: 1,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 0..=0,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 0..=0,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 0,
- },
- },
- size: Size {
- raw: 1,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 0,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 0,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ }
--> $DIR/hexagon-enum.rs:16:1
|
LL | enum A { Apple }
| ^^^^^^^^^^^^^^^^
error: layout_of(B) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 255..=255,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 0,
- },
- },
- size: Size {
- raw: 1,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 255..=255,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 255..=255,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 0,
- },
- },
- size: Size {
- raw: 1,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 255..=255,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 0,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 255..=255,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 255..=255,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 0,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ }
--> $DIR/hexagon-enum.rs:20:1
|
LL | enum B { Banana = 255, }
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(C) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I16,
- false,
- ),
- valid_range: 256..=256,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 1,
- },
- pref: Align {
- pow2: 1,
- },
- },
- size: Size {
- raw: 2,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I16,
- false,
- ),
- valid_range: 256..=256,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I16,
- false,
- ),
- valid_range: 256..=256,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 1,
- },
- pref: Align {
- pow2: 1,
- },
- },
- size: Size {
- raw: 2,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I16,
+ false,
+ ),
+ valid_range: 256..=256,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 1,
+ },
+ pref: Align {
+ pow2: 1,
+ },
+ },
+ size: Size {
+ raw: 2,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I16,
+ false,
+ ),
+ valid_range: 256..=256,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I16,
+ false,
+ ),
+ valid_range: 256..=256,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 1,
+ },
+ pref: Align {
+ pow2: 1,
+ },
+ },
+ size: Size {
+ raw: 2,
+ },
+ }
--> $DIR/hexagon-enum.rs:24:1
|
LL | enum C { Chaenomeles = 256, }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(P) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 268435456..=268435456,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 268435456..=268435456,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 268435456..=268435456,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 268435456..=268435456,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 268435456..=268435456,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 268435456..=268435456,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ }
--> $DIR/hexagon-enum.rs:28:1
|
LL | enum P { Peach = 0x1000_0000isize, }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(T) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 2164260864..=2164260864,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 2164260864..=2164260864,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 2164260864..=2164260864,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 2164260864..=2164260864,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 2164260864..=2164260864,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 2164260864..=2164260864,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ }
--> $DIR/hexagon-enum.rs:34:1
|
LL | enum T { Tangerine = TANGERINE as isize }
error: layout_of(A) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 0..=0,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 1,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 0..=0,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 0..=0,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 1,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 0..=0,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ }
--> $DIR/thumb-enum.rs:16:1
|
LL | enum A { Apple }
| ^^^^^^^^^^^^^^^^
error: layout_of(B) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 255..=255,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 1,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 255..=255,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I8,
- false,
- ),
- valid_range: 255..=255,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 0,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 1,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 255..=255,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 255..=255,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I8,
+ false,
+ ),
+ valid_range: 255..=255,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 0,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 1,
+ },
+ }
--> $DIR/thumb-enum.rs:20:1
|
LL | enum B { Banana = 255, }
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(C) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I16,
- false,
- ),
- valid_range: 256..=256,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 1,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 2,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I16,
- false,
- ),
- valid_range: 256..=256,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I16,
- false,
- ),
- valid_range: 256..=256,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 1,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 2,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I16,
+ false,
+ ),
+ valid_range: 256..=256,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 1,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 2,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I16,
+ false,
+ ),
+ valid_range: 256..=256,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I16,
+ false,
+ ),
+ valid_range: 256..=256,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 1,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 2,
+ },
+ }
--> $DIR/thumb-enum.rs:24:1
|
LL | enum C { Chaenomeles = 256, }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(P) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 268435456..=268435456,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 268435456..=268435456,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I32,
- false,
- ),
- valid_range: 268435456..=268435456,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 268435456..=268435456,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 268435456..=268435456,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I32,
+ false,
+ ),
+ valid_range: 268435456..=268435456,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ }
--> $DIR/thumb-enum.rs:28:1
|
LL | enum P { Peach = 0x1000_0000isize, }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: layout_of(T) = Layout {
- fields: Arbitrary {
- offsets: [
- Size {
- raw: 0,
- },
- ],
- memory_index: [
- 0,
- ],
- },
- variants: Multiple {
- tag: Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 2164260864..=2164260864,
- },
- tag_encoding: Direct,
- tag_field: 0,
- variants: [
- Layout {
- fields: Arbitrary {
- offsets: [],
- memory_index: [],
- },
- variants: Single {
- index: 0,
- },
- abi: Aggregate {
- sized: true,
- },
- largest_niche: None,
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
- },
- ],
- },
- abi: Scalar(
- Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 2164260864..=2164260864,
- },
- ),
- largest_niche: Some(
- Niche {
- offset: Size {
- raw: 0,
- },
- scalar: Scalar {
- value: Int(
- I32,
- true,
- ),
- valid_range: 2164260864..=2164260864,
- },
- },
- ),
- align: AbiAndPrefAlign {
- abi: Align {
- pow2: 2,
- },
- pref: Align {
- pow2: 2,
- },
- },
- size: Size {
- raw: 4,
- },
-}
+ fields: Arbitrary {
+ offsets: [
+ Size {
+ raw: 0,
+ },
+ ],
+ memory_index: [
+ 0,
+ ],
+ },
+ variants: Multiple {
+ tag: Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 2164260864..=2164260864,
+ },
+ tag_encoding: Direct,
+ tag_field: 0,
+ variants: [
+ Layout {
+ fields: Arbitrary {
+ offsets: [],
+ memory_index: [],
+ },
+ variants: Single {
+ index: 0,
+ },
+ abi: Aggregate {
+ sized: true,
+ },
+ largest_niche: None,
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ },
+ ],
+ },
+ abi: Scalar(
+ Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 2164260864..=2164260864,
+ },
+ ),
+ largest_niche: Some(
+ Niche {
+ offset: Size {
+ raw: 0,
+ },
+ scalar: Scalar {
+ value: Int(
+ I32,
+ true,
+ ),
+ valid_range: 2164260864..=2164260864,
+ },
+ },
+ ),
+ align: AbiAndPrefAlign {
+ abi: Align {
+ pow2: 2,
+ },
+ pref: Align {
+ pow2: 2,
+ },
+ },
+ size: Size {
+ raw: 4,
+ },
+ }
--> $DIR/thumb-enum.rs:34:1
|
LL | enum T { Tangerine = TANGERINE as isize }
+++ /dev/null
-// run-pass
-// pretty-expanded FIXME #23616
-
-fn leaky<T>(_t: T) { }
-
-pub fn main() {
- let x = Box::new(10);
- leaky::<Box<isize>>(x);
-}
| ^^^ cannot infer type for reference `&'a ()`
|
= note: cannot satisfy `&'a (): Foo`
-note: required by a bound in `Foo`
- --> $DIR/issue-34979.rs:1:1
- |
-LL | trait Foo {}
- | ^^^^^^^^^ required by this bound in `Foo`
error: aborting due to previous error
+++ /dev/null
-// run-pass
-// aux-build:link-cfg-works-transitive-rlib.rs
-// aux-build:link-cfg-works-transitive-dylib.rs
-
-#![feature(link_cfg)]
-
-extern crate link_cfg_works_transitive_dylib;
-extern crate link_cfg_works_transitive_rlib;
-
-#[link(name = "foo", cfg(foo))]
-extern "C" {}
-
-fn main() {}
--- /dev/null
+#![feature(link_cfg)]
+
+#[link(name = "foo", cfg(foo))]
+extern "C" {}
--- /dev/null
+// no-prefer-dynamic
+
+#![feature(link_cfg)]
+#![crate_type = "rlib"]
+
+#[link(name = "foo", cfg(foo))]
+extern "C" {}
--- /dev/null
+// run-pass
+// aux-build:link-cfg-works-transitive-rlib.rs
+// aux-build:link-cfg-works-transitive-dylib.rs
+
+#![feature(link_cfg)]
+
+extern crate link_cfg_works_transitive_dylib;
+extern crate link_cfg_works_transitive_rlib;
+
+#[link(name = "foo", cfg(foo))]
+extern "C" {}
+
+fn main() {}
+++ /dev/null
-// run-pass
-// compile-flags: --cap-lints allow
-
-#![deny(warnings)]
-
-use std::option;
-
-fn main() {}
// check-pass
-#![feature(inline_const)]
+#![feature(inline_const_pat)]
#![allow(incomplete_features)]
#![deny(dead_code)]
--- /dev/null
+// run-pass
+// compile-flags: --cap-lints allow
+
+#![deny(warnings)]
+
+use std::option;
+
+fn main() {}
--- /dev/null
+// Tests for repeating attribute warnings.
+// aux-build:lint_unused_extern_crate.rs
+// compile-flags:--test
+// Not tested due to extra requirements:
+// - panic_handler: needs extra setup
+// - target_feature: platform-specific
+// - link_section: platform-specific
+// - proc_macro, proc_macro_derive, proc_macro_attribute: needs to be a
+// proc-macro, and have special handling for mixing.
+// - unstable attributes (not going to bother)
+// - no_main: extra setup
+#![deny(unused_attributes)]
+#![crate_name = "unused_attr_duplicate"]
+#![crate_name = "unused_attr_duplicate2"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+#![crate_type = "bin"]
+#![crate_type = "rlib"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+#![recursion_limit = "128"]
+#![recursion_limit = "256"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+#![type_length_limit = "1048576"]
+#![type_length_limit = "1"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+#![no_std]
+#![no_std] //~ ERROR unused attribute
+#![no_implicit_prelude]
+#![no_implicit_prelude] //~ ERROR unused attribute
+#![windows_subsystem = "console"]
+#![windows_subsystem = "windows"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+#![no_builtins]
+#![no_builtins] //~ ERROR unused attribute
+
+#[no_link]
+#[no_link] //~ ERROR unused attribute
+extern crate lint_unused_extern_crate;
+
+#[macro_use]
+#[macro_use] //~ ERROR unused attribute
+pub mod m {
+ #[macro_export]
+ #[macro_export] //~ ERROR unused attribute
+ macro_rules! foo {
+ () => {};
+ }
+}
+
+#[path = "auxiliary/lint_unused_extern_crate.rs"]
+#[path = "bar.rs"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+pub mod from_path;
+
+#[test]
+#[ignore]
+#[ignore = "some text"] //~ ERROR unused attribute
+#[should_panic]
+#[should_panic(expected = "values don't match")] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+fn t1() {}
+
+#[must_use]
+#[must_use = "some message"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+// No warnings for #[repr], would require more logic.
+#[repr(C)]
+#[repr(C)]
+#[non_exhaustive]
+#[non_exhaustive] //~ ERROR unused attribute
+pub struct X;
+
+#[automatically_derived]
+#[automatically_derived] //~ ERROR unused attribute
+impl X {}
+
+#[inline(always)]
+#[inline(never)] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+#[cold]
+#[cold] //~ ERROR unused attribute
+#[track_caller]
+#[track_caller] //~ ERROR unused attribute
+pub fn xyz() {}
+
+// No warnings for #[link], would require more logic.
+#[link(name = "rust_test_helpers", kind = "static")]
+#[link(name = "rust_test_helpers", kind = "static")]
+extern "C" {
+ #[link_name = "this_does_not_exist"] //~ ERROR unused attribute
+ //~^ WARN this was previously accepted
+ #[link_name = "rust_dbg_extern_identity_u32"]
+ pub fn name_in_rust(v: u32) -> u32;
+}
+
+#[export_name = "exported_symbol_name"] //~ ERROR unused attribute
+//~^ WARN this was previously accepted
+#[export_name = "exported_symbol_name2"]
+pub fn export_test() {}
+
+#[no_mangle]
+#[no_mangle] //~ ERROR unused attribute
+pub fn no_mangle_test() {}
+
+#[used]
+#[used] //~ ERROR unused attribute
+static FOO: u32 = 0;
+
+fn main() {}
--- /dev/null
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:36:1
+ |
+LL | #[no_link]
+ | ^^^^^^^^^^ help: remove this attribute
+ |
+note: the lint level is defined here
+ --> $DIR/unused-attr-duplicate.rs:12:9
+ |
+LL | #![deny(unused_attributes)]
+ | ^^^^^^^^^^^^^^^^^
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:35:1
+ |
+LL | #[no_link]
+ | ^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:40:1
+ |
+LL | #[macro_use]
+ | ^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:39:1
+ |
+LL | #[macro_use]
+ | ^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:50:1
+ |
+LL | #[path = "bar.rs"]
+ | ^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:49:1
+ |
+LL | #[path = "auxiliary/lint_unused_extern_crate.rs"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:56:1
+ |
+LL | #[ignore = "some text"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:55:1
+ |
+LL | #[ignore]
+ | ^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:58:1
+ |
+LL | #[should_panic(expected = "values don't match")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:57:1
+ |
+LL | #[should_panic]
+ | ^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:63:1
+ |
+LL | #[must_use = "some message"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:62:1
+ |
+LL | #[must_use]
+ | ^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:69:1
+ |
+LL | #[non_exhaustive]
+ | ^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:68:1
+ |
+LL | #[non_exhaustive]
+ | ^^^^^^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:73:1
+ |
+LL | #[automatically_derived]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:72:1
+ |
+LL | #[automatically_derived]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:77:1
+ |
+LL | #[inline(never)]
+ | ^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:76:1
+ |
+LL | #[inline(always)]
+ | ^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:80:1
+ |
+LL | #[cold]
+ | ^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:79:1
+ |
+LL | #[cold]
+ | ^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:82:1
+ |
+LL | #[track_caller]
+ | ^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:81:1
+ |
+LL | #[track_caller]
+ | ^^^^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:95:1
+ |
+LL | #[export_name = "exported_symbol_name"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:97:1
+ |
+LL | #[export_name = "exported_symbol_name2"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:101:1
+ |
+LL | #[no_mangle]
+ | ^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:100:1
+ |
+LL | #[no_mangle]
+ | ^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:105:1
+ |
+LL | #[used]
+ | ^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:104:1
+ |
+LL | #[used]
+ | ^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:89:5
+ |
+LL | #[link_name = "this_does_not_exist"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:91:5
+ |
+LL | #[link_name = "rust_dbg_extern_identity_u32"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:14:1
+ |
+LL | #![crate_name = "unused_attr_duplicate2"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:13:1
+ |
+LL | #![crate_name = "unused_attr_duplicate"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:17:1
+ |
+LL | #![crate_type = "rlib"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:16:1
+ |
+LL | #![crate_type = "bin"]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:20:1
+ |
+LL | #![recursion_limit = "256"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:19:1
+ |
+LL | #![recursion_limit = "128"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:23:1
+ |
+LL | #![type_length_limit = "1"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:22:1
+ |
+LL | #![type_length_limit = "1048576"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:26:1
+ |
+LL | #![no_std]
+ | ^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:25:1
+ |
+LL | #![no_std]
+ | ^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:28:1
+ |
+LL | #![no_implicit_prelude]
+ | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:27:1
+ |
+LL | #![no_implicit_prelude]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:30:1
+ |
+LL | #![windows_subsystem = "windows"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:29:1
+ |
+LL | #![windows_subsystem = "console"]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:33:1
+ |
+LL | #![no_builtins]
+ | ^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:32:1
+ |
+LL | #![no_builtins]
+ | ^^^^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/unused-attr-duplicate.rs:43:5
+ |
+LL | #[macro_export]
+ | ^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/unused-attr-duplicate.rs:42:5
+ |
+LL | #[macro_export]
+ | ^^^^^^^^^^^^^^^
+
+error: aborting due to 24 previous errors
+
+++ /dev/null
-// run-pass
-
-#![allow(unreachable_code)]
-// pretty-expanded FIXME #23616
-
-#![allow(dead_code)]
-
-fn test() {
- let _v: isize;
- _v = 1;
- return;
- _v = 2;
-}
-
-pub fn main() {
-}
--- /dev/null
+// run-pass
+
+#![allow(unreachable_code)]
+// pretty-expanded FIXME #23616
+
+#![allow(dead_code)]
+
+fn test() {
+ let _v: isize;
+ _v = 1;
+ return;
+ _v = 2;
+}
+
+pub fn main() {
+}
+++ /dev/null
-// run-pass
-// aux-build:llvm_pr32379.rs
-
-// LLVM PR #32379 (https://bugs.llvm.org/show_bug.cgi?id=32379), which
-// applies to upstream LLVM 3.9.1, is known to cause rustc itself to be
-// miscompiled on ARM (Rust issue #40593). Because cross builds don't test
-// our *compiler* on ARM, have a test for the miscompilation directly.
-
-extern crate llvm_pr32379;
-
-pub fn main() {
- let val = llvm_pr32379::pr32379(2, false, false);
- assert_eq!(val, 2);
-}
+++ /dev/null
-error: lifetime may not live long enough
- --> $DIR/lub-if.rs:28:9
- |
-LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
- | -- lifetime `'a` defined here
-...
-LL | s
- | ^ returning this value requires that `'a` must outlive `'static`
-
-error: lifetime may not live long enough
- --> $DIR/lub-if.rs:35:9
- |
-LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
- | -- lifetime `'a` defined here
-...
-LL | s
- | ^ returning this value requires that `'a` must outlive `'static`
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-// Test that we correctly consider the type of `match` to be the LUB
-// of the various arms, particularly in the case where regions are
-// involved.
-
-pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
- if maybestr.is_none() {
- "(none)"
- } else {
- let s: &'a str = maybestr.as_ref().unwrap();
- s
- }
-}
-
-pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
- if maybestr.is_some() {
- let s: &'a str = maybestr.as_ref().unwrap();
- s
- } else {
- "(none)"
- }
-}
-
-pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
- if maybestr.is_none() {
- "(none)"
- } else {
- let s: &'a str = maybestr.as_ref().unwrap();
- s //~ ERROR E0312
- }
-}
-
-pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
- if maybestr.is_some() {
- let s: &'a str = maybestr.as_ref().unwrap();
- s //~ ERROR E0312
- } else {
- "(none)"
- }
-}
-
-
-fn main() {}
+++ /dev/null
-error[E0312]: lifetime of reference outlives lifetime of borrowed content...
- --> $DIR/lub-if.rs:28:9
- |
-LL | s
- | ^
- |
- = note: ...the reference is valid for the static lifetime...
-note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
- --> $DIR/lub-if.rs:23:17
- |
-LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
- | ^^
-
-error[E0312]: lifetime of reference outlives lifetime of borrowed content...
- --> $DIR/lub-if.rs:35:9
- |
-LL | s
- | ^
- |
- = note: ...the reference is valid for the static lifetime...
-note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
- --> $DIR/lub-if.rs:32:17
- |
-LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
- | ^^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0312`.
--> $DIR/macro-use-all-and-none.rs:7:1
|
LL | #[macro_use()]
- | ^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^ help: remove this attribute
|
note: the lint level is defined here
--> $DIR/macro-use-all-and-none.rs:4:9
|
LL | #![warn(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
+ = note: attribute `macro_use` with an empty list has no effect
warning: 1 warning emitted
+++ /dev/null
-use std::collections::HashMap;
-
-
-
-trait Map<K, V>
-{
- fn get(&self, k: K) -> V { panic!() }
-}
-
-impl<K, V> Map<K, V> for HashMap<K, V> {}
-
-// Test that trait types printed in error msgs include the type arguments.
-
-fn main() {
- let x: Box<HashMap<isize, isize>> = HashMap::new().into();
- let x: Box<dyn Map<isize, isize>> = x;
- let y: Box<dyn Map<usize, isize>> = Box::new(x);
- //~^ ERROR `Box<dyn Map<isize, isize>>: Map<usize, isize>` is not satisfied
-}
+++ /dev/null
-error[E0277]: the trait bound `Box<dyn Map<isize, isize>>: Map<usize, isize>` is not satisfied
- --> $DIR/map-types.rs:17:41
- |
-LL | let y: Box<dyn Map<usize, isize>> = Box::new(x);
- | ^^^^^^^^^^^ the trait `Map<usize, isize>` is not implemented for `Box<dyn Map<isize, isize>>`
- |
- = note: required for the cast to the object type `dyn Map<usize, isize>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | impl<'a> A for (&'a (), &'static ()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: required by a bound in `A`
- --> $DIR/region-overlap.rs:4:1
- |
-LL | trait A {}
- | ^^^^^^^ required by this bound in `A`
error[E0283]: type annotations needed
--> $DIR/region-overlap.rs:6:10
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | impl<'a> A for (&'a (), &'static ()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: required by a bound in `A`
- --> $DIR/region-overlap.rs:4:1
- |
-LL | trait A {}
- | ^^^^^^^ required by this bound in `A`
error: aborting due to 2 previous errors
+++ /dev/null
-// run-pass
-
-fn main() {
- assert_eq!(false, match -50_i8 { -128i8..=-101i8 => true, _ => false, });
-
- assert_eq!(false, if let -128i8..=-101i8 = -50_i8 { true } else { false });
-}
--- /dev/null
+struct S(());
+
+fn main() {
+ let array = [S(())];
+
+ match array {
+ [()] => {}
+ //~^ ERROR mismatched types [E0308]
+ _ => {}
+ }
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/issue-91058.rs:7:10
+ |
+LL | match array {
+ | ----- this expression has type `[S; 1]`
+LL | [()] => {}
+ | ^^ expected struct `S`, found `()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// run-pass
+
+fn main() {
+ assert_eq!(false, match -50_i8 { -128i8..=-101i8 => true, _ => false, });
+
+ assert_eq!(false, if let -128i8..=-101i8 = -50_i8 { true } else { false });
+}
+++ /dev/null
-// run-pass
-// edition:2021
-
-// regression test for https://github.com/rust-lang/rust/pull/85678
-
-#![feature(assert_matches)]
-
-use std::assert_matches::assert_matches;
-
-fn main() {
- assert!(matches!((), ()));
- assert_matches!((), ());
-}
+++ /dev/null
-struct S1<T>(T) where (T): ?Sized;
-//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
-
-struct S2<T>(T) where u8: ?Sized;
-//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
-
-struct S3<T>(T) where &'static T: ?Sized;
-//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
-
-trait Trait<'a> {}
-
-struct S4<T>(T) where for<'a> T: ?Trait<'a>;
-//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
-//~| WARN default bound relaxed for a type parameter
-
-struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
-//~^ ERROR type parameter has more than one relaxed default bound
-//~| WARN default bound relaxed for a type parameter
-
-impl<T> S1<T> {
- fn f() where T: ?Sized {}
- //~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
-}
-
-fn main() {
- let u = vec![1, 2, 3];
- let _s: S5<[u8]> = S5(&u[..]); // OK
-}
+++ /dev/null
-error: `?Trait` bounds are only permitted at the point where a type parameter is declared
- --> $DIR/maybe-bounds-where.rs:1:28
- |
-LL | struct S1<T>(T) where (T): ?Sized;
- | ^^^^^^
-
-error: `?Trait` bounds are only permitted at the point where a type parameter is declared
- --> $DIR/maybe-bounds-where.rs:4:27
- |
-LL | struct S2<T>(T) where u8: ?Sized;
- | ^^^^^^
-
-error: `?Trait` bounds are only permitted at the point where a type parameter is declared
- --> $DIR/maybe-bounds-where.rs:7:35
- |
-LL | struct S3<T>(T) where &'static T: ?Sized;
- | ^^^^^^
-
-error: `?Trait` bounds are only permitted at the point where a type parameter is declared
- --> $DIR/maybe-bounds-where.rs:12:34
- |
-LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>;
- | ^^^^^^^^^^
-
-error: `?Trait` bounds are only permitted at the point where a type parameter is declared
- --> $DIR/maybe-bounds-where.rs:21:21
- |
-LL | fn f() where T: ?Sized {}
- | ^^^^^^
-
-warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
- --> $DIR/maybe-bounds-where.rs:12:11
- |
-LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>;
- | ^
-
-error[E0203]: type parameter has more than one relaxed default bound, only one is supported
- --> $DIR/maybe-bounds-where.rs:16:11
- |
-LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
- | ^
-
-warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
- --> $DIR/maybe-bounds-where.rs:16:11
- |
-LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
- | ^
-
-error: aborting due to 6 previous errors; 2 warnings emitted
-
-For more information about this error, try `rustc --explain E0203`.
+++ /dev/null
-// run-pass
-
-use std::fmt::Debug;
-use std::cmp::{self, PartialOrd, Ordering};
-
-#[derive(Debug, Copy, Clone, PartialEq, Eq)]
-struct Foo {
- n: u8,
- name: &'static str
-}
-
-impl PartialOrd for Foo {
- fn partial_cmp(&self, other: &Foo) -> Option<Ordering> {
- Some(self.cmp(other))
- }
-}
-
-impl Ord for Foo {
- fn cmp(&self, other: &Foo) -> Ordering {
- self.n.cmp(&other.n)
- }
-}
-
-fn main() {
- let a = Foo { n: 4, name: "a" };
- let b = Foo { n: 4, name: "b" };
- let c = Foo { n: 8, name: "c" };
- let d = Foo { n: 8, name: "d" };
- let e = Foo { n: 22, name: "e" };
- let f = Foo { n: 22, name: "f" };
-
- let data = [a, b, c, d, e, f];
-
- // `min` should return the left when the values are equal
- assert_eq!(data.iter().min(), Some(&a));
- assert_eq!(data.iter().min_by_key(|a| a.n), Some(&a));
- assert_eq!(cmp::min(a, b), a);
- assert_eq!(cmp::min(b, a), b);
-
- // `max` should return the right when the values are equal
- assert_eq!(data.iter().max(), Some(&f));
- assert_eq!(data.iter().max_by_key(|a| a.n), Some(&f));
- assert_eq!(cmp::max(e, f), f);
- assert_eq!(cmp::max(f, e), e);
-
- let mut presorted = data.to_vec();
- presorted.sort();
- assert_stable(&presorted);
-
- let mut presorted = data.to_vec();
- presorted.sort_by(|a, b| a.cmp(b));
- assert_stable(&presorted);
-
- // Assert that sorted and min/max are the same
- fn assert_stable<T: Ord + Debug>(presorted: &[T]) {
- for slice in presorted.windows(2) {
- let a = &slice[0];
- let b = &slice[1];
-
- assert_eq!(a, cmp::min(a, b));
- assert_eq!(b, cmp::max(a, b));
- }
- }
-}
--- /dev/null
+// build-pass
+// compile-flags:-Copt-level=0
+// edition:2018
+
+struct S<T>(std::marker::PhantomData<T>);
+
+impl<T> std::ops::Deref for S<T> {
+ type Target = T;
+
+ fn deref(&self) -> &Self::Target {
+ todo!()
+ }
+}
+impl<T> std::ops::DerefMut for S<T> {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ todo!()
+ }
+}
+
+async fn new() -> S<u64> {
+ todo!()
+}
+
+async fn crash() {
+ *new().await = 1 + 1;
+}
+
+fn main() {
+ let _ = crash();
+}
LL | fn b() -> Option<Foo> {
| ----------- expected `Option<Foo>` because of return type
LL | Foo { bar: 1 }
- | ^^^^^^^^^^^^^^
- | |
- | expected enum `Option`, found struct `Foo`
- | help: try using a variant of the expected enum: `Some(Foo { bar: 1 })`
+ | ^^^^^^^^^^^^^^ expected enum `Option`, found struct `Foo`
|
= note: expected enum `Option<Foo>`
found struct `Foo`
+help: try wrapping the expression in `Some`
+ |
+LL | Some(Foo { bar: 1 })
+ | +++++ +
error[E0308]: mismatched types
--> $DIR/abridged.rs:28:5
LL | fn c() -> Result<Foo, Bar> {
| ---------------- expected `Result<Foo, Bar>` because of return type
LL | Foo { bar: 1 }
- | ^^^^^^^^^^^^^^
- | |
- | expected enum `Result`, found struct `Foo`
- | help: try using a variant of the expected enum: `Ok(Foo { bar: 1 })`
+ | ^^^^^^^^^^^^^^ expected enum `Result`, found struct `Foo`
|
= note: expected enum `Result<Foo, Bar>`
found struct `Foo`
+help: try wrapping the expression in `Ok`
+ |
+LL | Ok(Foo { bar: 1 })
+ | +++ +
error[E0308]: mismatched types
--> $DIR/abridged.rs:39:5
--- /dev/null
+struct Foo;
+
+fn main() {
+ let mut a = Foo;
+ let ref b = Foo;
+ a += *b; //~ Error: binary assignment operation `+=` cannot be applied to type `Foo`
+}
--- /dev/null
+error[E0368]: binary assignment operation `+=` cannot be applied to type `Foo`
+ --> $DIR/assignment-operator-unimplemented.rs:6:3
+ |
+LL | a += *b;
+ | -^^^^^^
+ | |
+ | cannot use `+=` on type `Foo`
+ |
+note: an implementation of `AddAssign<_>` might be missing for `Foo`
+ --> $DIR/assignment-operator-unimplemented.rs:1:1
+ |
+LL | struct Foo;
+ | ^^^^^^^^^^^ must implement `AddAssign<_>`
+note: the following trait must be implemented
+ --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
+ |
+LL | / pub trait AddAssign<Rhs = Self> {
+LL | | /// Performs the `+=` operation.
+LL | | ///
+LL | | /// # Example
+... |
+LL | | fn add_assign(&mut self, rhs: Rhs);
+LL | | }
+ | |_^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0368`.
...
LL | fn foo() {}
| -------- takes 0 arguments
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments
--> $DIR/closure-arg-count.rs:27:57
| --- ^^^ expected closure that takes a single 2-tuple as argument
| |
| required by a bound introduced by this call
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
--> $DIR/closure-arg-count.rs:29:57
...
LL | fn qux(x: usize, y: usize) {}
| -------------------------- takes 2 distinct arguments
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0593]: function is expected to take 1 argument, but it takes 2 arguments
--> $DIR/closure-arg-count.rs:32:45
| --- ^^^^^^^^^^^^^^^^^^ expected function that takes 1 argument
| |
| required by a bound introduced by this call
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
--> $DIR/closure-arg-count.rs:35:10
| ^^^ ------------------ found signature of `fn((u32, u32)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0631]: type mismatch in closure arguments
--> $DIR/closure-arg-type-mismatch.rs:4:14
| ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0631]: type mismatch in closure arguments
--> $DIR/closure-arg-type-mismatch.rs:5:14
| ^^^ ------------------ found signature of `fn((u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error: aborting due to 3 previous errors
| ^^^ ------------------ found signature of `fn((u32, u32)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0631]: type mismatch in closure arguments
--> $DIR/closure-arg-type-mismatch.rs:4:14
| ^^^ ------------------- found signature of `for<'r> fn(&'r (u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0631]: type mismatch in closure arguments
--> $DIR/closure-arg-type-mismatch.rs:5:14
| ^^^ ------------------ found signature of `fn((u16, u16)) -> _`
| |
| expected signature of `fn(&(u32, u32)) -> _`
+ |
+note: required by a bound in `map`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | F: FnMut(Self::Item) -> B,
+ | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0308]: mismatched types
--> $DIR/closure-arg-type-mismatch.rs:10:5
--- /dev/null
+fn main() {
+ let x: f32 = 1; //~ ERROR mismatched types
+ let y: f32 = 1f64; //~ ERROR mismatched types
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/float-literal-inference-restrictions.rs:2:18
+ |
+LL | let x: f32 = 1;
+ | --- ^
+ | | |
+ | | expected `f32`, found integer
+ | | help: use a float literal: `1.0`
+ | expected due to this
+
+error[E0308]: mismatched types
+ --> $DIR/float-literal-inference-restrictions.rs:3:18
+ |
+LL | let y: f32 = 1f64;
+ | --- ^^^^ expected `f32`, found `f64`
+ | |
+ | expected due to this
+ |
+help: change the type of the numeric literal from `f64` to `f32`
+ |
+LL | let y: f32 = 1f32;
+ | ~~~
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
| ^^^^^^ -------------- found signature of `for<'r> fn(&'r str) -> _`
| |
| expected signature of `for<'r> fn(&'r &str) -> _`
+ |
+note: required by a bound in `filter`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+ |
+LL | P: FnMut(&Self::Item) -> bool,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `filter`
error[E0599]: the method `count` exists for struct `Filter<Fuse<std::iter::Once<&str>>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]>`, but its trait bounds were not satisfied
--> $DIR/issue-36053-2.rs:7:55
--- /dev/null
+#[derive(Clone)]
+pub struct Struct<A>(A);
+
+impl<A> Struct<A> {
+ pub fn new() -> Self {
+ todo!()
+ }
+}
--- /dev/null
+// run-rustfix
+#![allow(dead_code)]
+use std::collections::HashSet;
+use std::hash::Hash;
+
+fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool where T: Eq, T: Hash {
+ this.is_subset(other)
+ //~^ ERROR the method
+}
+
+fn main() {}
--- /dev/null
+// run-rustfix
+#![allow(dead_code)]
+use std::collections::HashSet;
+use std::hash::Hash;
+
+fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool {
+ this.is_subset(other)
+ //~^ ERROR the method
+}
+
+fn main() {}
--- /dev/null
+error[E0599]: the method `is_subset` exists for reference `&HashSet<T>`, but its trait bounds were not satisfied
+ --> $DIR/issue-35677.rs:7:10
+ |
+LL | this.is_subset(other)
+ | ^^^^^^^^^ method cannot be called on `&HashSet<T>` due to unsatisfied trait bounds
+ |
+ = note: the following trait bounds were not satisfied:
+ `T: Eq`
+ `T: Hash`
+help: consider restricting the type parameters to satisfy the trait bounds
+ |
+LL | fn is_subset<T>(this: &HashSet<T>, other: &HashSet<T>) -> bool where T: Eq, T: Hash {
+ | ++++++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
--- /dev/null
+// run-rustfix
+// aux-build:issue-69725.rs
+#![allow(dead_code)]
+
+extern crate issue_69725;
+use issue_69725::Struct;
+
+fn crash<A>() where A: Clone {
+ let _ = Struct::<A>::new().clone();
+ //~^ ERROR: the method
+}
+
+fn main() {}
--- /dev/null
+// run-rustfix
+// aux-build:issue-69725.rs
+#![allow(dead_code)]
+
+extern crate issue_69725;
+use issue_69725::Struct;
+
+fn crash<A>() {
+ let _ = Struct::<A>::new().clone();
+ //~^ ERROR: the method
+}
+
+fn main() {}
--- /dev/null
+error[E0599]: the method `clone` exists for struct `Struct<A>`, but its trait bounds were not satisfied
+ --> $DIR/issue-69725.rs:9:32
+ |
+LL | let _ = Struct::<A>::new().clone();
+ | ^^^^^ method cannot be called on `Struct<A>` due to unsatisfied trait bounds
+ |
+ ::: $DIR/auxiliary/issue-69725.rs:2:1
+ |
+LL | pub struct Struct<A>(A);
+ | ------------------------ doesn't satisfy `Struct<A>: Clone`
+ |
+ = note: the following trait bounds were not satisfied:
+ `A: Clone`
+ which is required by `Struct<A>: Clone`
+help: consider restricting the type parameter to satisfy the trait bound
+ |
+LL | fn crash<A>() where A: Clone {
+ | ++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
--- /dev/null
+// run-rustfix
+
+pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) {
+ let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]`
+}
+
+fn main() {}
--- /dev/null
+// run-rustfix
+
+pub fn foo<T>(s: &[T], t: &[T]) {
+ let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]`
+}
+
+fn main() {}
--- /dev/null
+error[E0369]: binary operation `==` cannot be applied to type `&[T]`
+ --> $DIR/missing-trait-bound-for-op.rs:4:15
+ |
+LL | let _ = s == t;
+ | - ^^ - &[T]
+ | |
+ | &[T]
+ |
+help: consider restricting type parameter `T`
+ |
+LL | pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) {
+ | +++++++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0369`.
--- /dev/null
+#[derive(Default, PartialEq)]
+struct Foo<T> {
+ bar: Box<[T]>,
+}
+
+trait Bar {
+ fn foo(&self) {}
+}
+
+impl<T: Default + Bar> Bar for Foo<T> {}
+
+impl<T> Foo<T> {
+ fn bar(&self) {
+ self.foo();
+ //~^ ERROR the method
+ }
+}
+
+struct Fin<T> where T: Bar {
+ bar: Box<[T]>,
+}
+
+impl<T: Default + Bar> Bar for Fin<T> {}
+
+impl<T: Bar> Fin<T> {
+ fn bar(&self) {
+ self.foo();
+ //~^ ERROR the method
+ }
+}
+fn main() {}
--- /dev/null
+error[E0599]: the method `foo` exists for reference `&Foo<T>`, but its trait bounds were not satisfied
+ --> $DIR/missing-trait-bounds-for-method-call.rs:14:14
+ |
+LL | struct Foo<T> {
+ | ------------- doesn't satisfy `Foo<T>: Bar`
+...
+LL | self.foo();
+ | ^^^ method cannot be called on `&Foo<T>` due to unsatisfied trait bounds
+ |
+ = note: the following trait bounds were not satisfied:
+ `T: Default`
+ which is required by `Foo<T>: Bar`
+ `T: Bar`
+ which is required by `Foo<T>: Bar`
+help: consider restricting the type parameters to satisfy the trait bounds
+ |
+LL | struct Foo<T> where T: Bar, T: Default {
+ | ++++++++++++++++++++++++
+
+error[E0599]: the method `foo` exists for reference `&Fin<T>`, but its trait bounds were not satisfied
+ --> $DIR/missing-trait-bounds-for-method-call.rs:27:14
+ |
+LL | struct Fin<T> where T: Bar {
+ | -------------------------- doesn't satisfy `Fin<T>: Bar`
+...
+LL | self.foo();
+ | ^^^ method cannot be called on `&Fin<T>` due to unsatisfied trait bounds
+ |
+ = note: the following trait bounds were not satisfied:
+ `T: Default`
+ which is required by `Fin<T>: Bar`
+help: consider restricting the type parameter to satisfy the trait bound
+ |
+LL | struct Fin<T> where T: Bar, T: Default {
+ | ++++++++++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0599`.
mod $name;
pub use self::$name;
//~^ ERROR the name `issue_56411_aux` is defined multiple times
- //~| ERROR `issue_56411_aux` is private, and cannot be re-exported
+ //~| ERROR `issue_56411_aux` is only public within the crate, and cannot be re-exported outside
)*
}
= note: `issue_56411_aux` must be defined only once in the type namespace of this module
= note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
-error[E0365]: `issue_56411_aux` is private, and cannot be re-exported
+error[E0365]: `issue_56411_aux` is only public within the crate, and cannot be re-exported outside
--> $DIR/issue-56411.rs:6:21
|
LL | pub use self::$name;
- | ^^^^^^^^^^^ re-export of private `issue_56411_aux`
+ | ^^^^^^^^^^^ re-export of crate public `issue_56411_aux`
...
LL | import!(("issue-56411-aux.rs", issue_56411_aux));
| ------------------------------------------------ in this macro invocation
--- /dev/null
+// Ensure that taking a mutable raw ptr to an uninitialized variable does not change its
+// initializedness.
+
+struct S;
+
+fn main() {
+ let mut x: S;
+ std::ptr::addr_of_mut!(x); //~ borrow of
+
+ let y = x; // Should error here if `addr_of_mut` is ever allowed on uninitialized variables
+ drop(y);
+}
--- /dev/null
+error[E0381]: borrow of possibly-uninitialized variable: `x`
+ --> $DIR/move-of-addr-of-mut.rs:8:5
+ |
+LL | std::ptr::addr_of_mut!(x);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `x`
+ |
+ = note: this error originates in the macro `std::ptr::addr_of_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0381`.
+++ /dev/null
-// run-pass
-// ignore-emscripten no processes
-// ignore-sgx no processes
-
-fn check_for_no_backtrace(test: std::process::Output) {
- assert!(!test.status.success());
- let err = String::from_utf8_lossy(&test.stderr);
- let mut it = err.lines();
-
- assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true));
- assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \
- environment variable to display a backtrace"));
- assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
- assert_eq!(it.next(), None);
-}
-
-fn main() {
- let args: Vec<String> = std::env::args().collect();
- if args.len() > 1 && args[1] == "run_test" {
- let _ = std::thread::spawn(|| {
- panic!();
- }).join();
-
- panic!();
- } else {
- let test = std::process::Command::new(&args[0]).arg("run_test")
- .env_remove("RUST_BACKTRACE")
- .output()
- .unwrap();
- check_for_no_backtrace(test);
- let test = std::process::Command::new(&args[0]).arg("run_test")
- .env("RUST_BACKTRACE","0")
- .output()
- .unwrap();
- check_for_no_backtrace(test);
- }
-}
+++ /dev/null
-// run-pass
-
-#![feature(start)]
-
-#[start]
-pub fn main(_: isize, _: *const *const u8) -> isize {
- println!("hello");
- 0
-}
|
= help: the following implementations were found:
<E as From<!>>
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-// Test that the lambda kind is inferred correctly as a return
-// expression
-
-// pretty-expanded FIXME #23616
-
-fn unique() -> Box<dyn FnMut()+'static> { return Box::new(|| ()); }
-
-pub fn main() {
-}
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-// Test that the lambda kind is inferred correctly as a return
-// expression
-
-// pretty-expanded FIXME #23616
-
-fn unique() -> Box<dyn FnMut()+'static> { Box::new(|| ()) }
-
-pub fn main() {
-}
+++ /dev/null
-// run-pass
-
-#[derive(PartialEq, Debug)]
-struct Foo(usize);
-
-fn foo() -> Foo {
- Foo(42)
-}
-
-pub fn main() {
- assert_eq!(foo(), Foo(42));
-}
--> $DIR/dont-print-desugared.rs:4:10
|
LL | for &ref mut x in s {}
- | ^^^^^^^^^ cannot borrow as mutable through `&` reference
+ | ^^^^^^^^^ cannot borrow as mutable
error[E0597]: `y` does not live long enough
--> $DIR/dont-print-desugared.rs:17:16
--> $DIR/issue-53773.rs:41:22
|
LL | members.push(child.raw);
- | ^^^^^^^^^
+ | -------------^^^^^^^^^- borrow later used here
LL |
LL | }
| - here, drop of `child` needs exclusive access to `*child.raw`, because the type `C<'_>` implements the `Drop` trait
-LL | members.len();
- | ------------- borrow later used here
|
= note: consider using a `let` binding to create a longer lived value
--- /dev/null
+error: lifetime may not live long enough
+ --> $DIR/lub-if.rs:28:9
+ |
+LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
+ | -- lifetime `'a` defined here
+...
+LL | s
+ | ^ returning this value requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+ --> $DIR/lub-if.rs:35:9
+ |
+LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
+ | -- lifetime `'a` defined here
+...
+LL | s
+ | ^ returning this value requires that `'a` must outlive `'static`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Test that we correctly consider the type of `match` to be the LUB
+// of the various arms, particularly in the case where regions are
+// involved.
+
+pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
+ if maybestr.is_none() {
+ "(none)"
+ } else {
+ let s: &'a str = maybestr.as_ref().unwrap();
+ s
+ }
+}
+
+pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
+ if maybestr.is_some() {
+ let s: &'a str = maybestr.as_ref().unwrap();
+ s
+ } else {
+ "(none)"
+ }
+}
+
+pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
+ if maybestr.is_none() {
+ "(none)"
+ } else {
+ let s: &'a str = maybestr.as_ref().unwrap();
+ s //~ ERROR E0312
+ }
+}
+
+pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
+ if maybestr.is_some() {
+ let s: &'a str = maybestr.as_ref().unwrap();
+ s //~ ERROR E0312
+ } else {
+ "(none)"
+ }
+}
+
+
+fn main() {}
--- /dev/null
+error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+ --> $DIR/lub-if.rs:28:9
+ |
+LL | s
+ | ^
+ |
+ = note: ...the reference is valid for the static lifetime...
+note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
+ --> $DIR/lub-if.rs:23:17
+ |
+LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
+ | ^^
+
+error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+ --> $DIR/lub-if.rs:35:9
+ |
+LL | s
+ | ^
+ |
+ = note: ...the reference is valid for the static lifetime...
+note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
+ --> $DIR/lub-if.rs:32:17
+ |
+LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
+ | ^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0312`.
+++ /dev/null
-// aux-build: no-mangle-associated-fn.rs
-// run-pass
-
-extern crate no_mangle_associated_fn;
-
-struct Foo;
-
-impl Foo {
- #[no_mangle]
- fn foo() -> u8 {
- 1
- }
-}
-
-trait Bar {
- fn qux() -> u8;
-}
-
-impl Bar for Foo {
- #[no_mangle]
- fn qux() -> u8 {
- 4
- }
-}
-
-fn main() {
- extern "Rust" {
- fn foo() -> u8;
- fn bar() -> u8;
- fn baz() -> u8;
- fn qux() -> u8;
- }
- assert_eq!(unsafe { foo() }, 1);
- assert_eq!(unsafe { bar() }, 2);
- assert_eq!(unsafe { baz() }, 3);
- assert_eq!(unsafe { qux() }, 4);
-}
+++ /dev/null
-// run-pass
-
-#![no_std]
-
-extern crate std;
-
-fn main() {
- let a = Some("foo");
- a.unwrap();
-}
+++ /dev/null
-// run-pass
-
-#![no_std]
-
-extern crate std;
-
-fn main() {
- let a = core::option::Option::Some("foo");
- a.unwrap();
-}
+++ /dev/null
-// run-pass
-
-#![no_std]
-
-extern crate std;
-
-mod foo {
- pub fn test() -> Option<i32> {
- Some(2)
- }
-}
-
-fn main() {
- let a = core::option::Option::Some("foo");
- a.unwrap();
- foo::test().unwrap();
-}
+++ /dev/null
-// run-pass
-// ignore-android
-// ignore-emscripten no processes
-// ignore-sgx no processes
-// revisions: mir thir
-// [thir]compile-flags: -Zthir-unsafeck
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-use std::process::{Command, Stdio};
-use std::env;
-use std::io::{self, Read, Write};
-
-#[cfg(unix)]
-unsafe fn without_stdio<R, F: FnOnce() -> R>(f: F) -> R {
- let doit = |a| {
- let r = libc::dup(a);
- assert!(r >= 0);
- return r
- };
- let a = doit(0);
- let b = doit(1);
- let c = doit(2);
-
- assert!(libc::close(0) >= 0);
- assert!(libc::close(1) >= 0);
- assert!(libc::close(2) >= 0);
-
- let r = f();
-
- assert!(libc::dup2(a, 0) >= 0);
- assert!(libc::dup2(b, 1) >= 0);
- assert!(libc::dup2(c, 2) >= 0);
-
- return r
-}
-
-#[cfg(unix)]
-fn assert_fd_is_valid(fd: libc::c_int) {
- if unsafe { libc::fcntl(fd, libc::F_GETFD) == -1 } {
- panic!("file descriptor {} is not valid: {}", fd, io::Error::last_os_error());
- }
-}
-
-#[cfg(windows)]
-fn assert_fd_is_valid(_fd: libc::c_int) {}
-
-#[cfg(windows)]
-unsafe fn without_stdio<R, F: FnOnce() -> R>(f: F) -> R {
- type DWORD = u32;
- type HANDLE = *mut u8;
- type BOOL = i32;
-
- const STD_INPUT_HANDLE: DWORD = -10i32 as DWORD;
- const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
- const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
- const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
-
- extern "system" {
- fn GetStdHandle(which: DWORD) -> HANDLE;
- fn SetStdHandle(which: DWORD, handle: HANDLE) -> BOOL;
- }
-
- let doit = |id| {
- let handle = GetStdHandle(id);
- assert!(handle != INVALID_HANDLE_VALUE);
- assert!(SetStdHandle(id, INVALID_HANDLE_VALUE) != 0);
- return handle
- };
-
- let a = doit(STD_INPUT_HANDLE);
- let b = doit(STD_OUTPUT_HANDLE);
- let c = doit(STD_ERROR_HANDLE);
-
- let r = f();
-
- let doit = |id, handle| {
- assert!(SetStdHandle(id, handle) != 0);
- };
- doit(STD_INPUT_HANDLE, a);
- doit(STD_OUTPUT_HANDLE, b);
- doit(STD_ERROR_HANDLE, c);
-
- return r
-}
-
-fn main() {
- if env::args().len() > 1 {
- // Writing to stdout & stderr should not panic.
- println!("test");
- assert!(io::stdout().write(b"test\n").is_ok());
- assert!(io::stderr().write(b"test\n").is_ok());
-
- // Stdin should be at EOF.
- assert_eq!(io::stdin().read(&mut [0; 10]).unwrap(), 0);
-
- // Standard file descriptors should be valid on UNIX:
- assert_fd_is_valid(0);
- assert_fd_is_valid(1);
- assert_fd_is_valid(2);
- return
- }
-
- // First, make sure reads/writes without stdio work if stdio itself is
- // missing.
- let (a, b, c) = unsafe {
- without_stdio(|| {
- let a = io::stdout().write(b"test\n");
- let b = io::stderr().write(b"test\n");
- let c = io::stdin().read(&mut [0; 10]);
-
- (a, b, c)
- })
- };
-
- assert_eq!(a.unwrap(), 5);
- assert_eq!(b.unwrap(), 5);
- assert_eq!(c.unwrap(), 0);
-
- // Second, spawn a child and do some work with "null" descriptors to make
- // sure it's ok
- let me = env::current_exe().unwrap();
- let status = Command::new(&me)
- .arg("next")
- .stdin(Stdio::null())
- .stdout(Stdio::null())
- .stderr(Stdio::null())
- .status().unwrap();
- assert!(status.success(), "{} isn't a success", status);
-
- // Finally, close everything then spawn a child to make sure everything is
- // *still* ok.
- let status = unsafe {
- without_stdio(|| Command::new(&me).arg("next").status())
- }.unwrap();
- assert!(status.success(), "{} isn't a success", status);
-}
+++ /dev/null
-// Related issues: #20401, #20506, #20614, #20752, #20829, #20846, #20885, #20886
-
-fn main() {
- "".homura[""]; //~ no field `homura` on type `&'static str`
-}
+++ /dev/null
-error[E0609]: no field `homura` on type `&'static str`
- --> $DIR/no-type-for-node-ice.rs:4:8
- |
-LL | "".homura[""];
- | ^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0609`.
+++ /dev/null
-#![feature(negative_impls)]
-
-use std::marker::Send;
-
-struct Foo {
- a: isize,
-}
-
-impl !Send for Foo {}
-
-fn bar<T: Send>(_: T) {}
-
-fn main() {
- let x = Foo { a: 5 };
- bar(x);
- //~^ ERROR `Foo` cannot be sent between threads safely
-}
+++ /dev/null
-error[E0277]: `Foo` cannot be sent between threads safely
- --> $DIR/no_send-struct.rs:15:9
- |
-LL | bar(x);
- | --- ^ `Foo` cannot be sent between threads safely
- | |
- | required by a bound introduced by this call
- |
- = help: the trait `Send` is not implemented for `Foo`
-note: required by a bound in `bar`
- --> $DIR/no_send-struct.rs:11:11
- |
-LL | fn bar<T: Send>(_: T) {}
- | ^^^^ required by this bound in `bar`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
+++ /dev/null
-// run-pass
-
-struct X {
- repr: isize
-}
-
-fn apply<T, F>(x: T, f: F) where F: FnOnce(T) {
- f(x);
-}
-
-fn check_int(x: isize) {
- assert_eq!(x, 22);
-}
-
-fn check_struct(x: X) {
- check_int(x.repr);
-}
-
-pub fn main() {
- apply(22, check_int);
- apply(X {repr: 22}, check_struct);
-}
+++ /dev/null
-use std::cell::{Cell, RefCell};
-use std::rc::{Rc, Weak};
-use std::sync::mpsc::{Receiver, Sender};
-
-fn test<T: Sync>() {}
-
-fn main() {
- test::<Cell<i32>>();
- //~^ ERROR `Cell<i32>` cannot be shared between threads safely [E0277]
- test::<RefCell<i32>>();
- //~^ ERROR `RefCell<i32>` cannot be shared between threads safely [E0277]
-
- test::<Rc<i32>>();
- //~^ ERROR `Rc<i32>` cannot be shared between threads safely [E0277]
- test::<Weak<i32>>();
- //~^ ERROR `std::rc::Weak<i32>` cannot be shared between threads safely [E0277]
-
- test::<Receiver<i32>>();
- //~^ ERROR `std::sync::mpsc::Receiver<i32>` cannot be shared between threads safely [E0277]
- test::<Sender<i32>>();
- //~^ ERROR `Sender<i32>` cannot be shared between threads safely [E0277]
-}
+++ /dev/null
-error[E0277]: `Cell<i32>` cannot be shared between threads safely
- --> $DIR/not-sync.rs:8:12
- |
-LL | test::<Cell<i32>>();
- | ^^^^^^^^^ `Cell<i32>` cannot be shared between threads safely
- |
- = help: the trait `Sync` is not implemented for `Cell<i32>`
-note: required by a bound in `test`
- --> $DIR/not-sync.rs:5:12
- |
-LL | fn test<T: Sync>() {}
- | ^^^^ required by this bound in `test`
-
-error[E0277]: `RefCell<i32>` cannot be shared between threads safely
- --> $DIR/not-sync.rs:10:12
- |
-LL | test::<RefCell<i32>>();
- | ^^^^^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely
- |
- = help: the trait `Sync` is not implemented for `RefCell<i32>`
-note: required by a bound in `test`
- --> $DIR/not-sync.rs:5:12
- |
-LL | fn test<T: Sync>() {}
- | ^^^^ required by this bound in `test`
-
-error[E0277]: `Rc<i32>` cannot be shared between threads safely
- --> $DIR/not-sync.rs:13:12
- |
-LL | test::<Rc<i32>>();
- | ^^^^^^^ `Rc<i32>` cannot be shared between threads safely
- |
- = help: the trait `Sync` is not implemented for `Rc<i32>`
-note: required by a bound in `test`
- --> $DIR/not-sync.rs:5:12
- |
-LL | fn test<T: Sync>() {}
- | ^^^^ required by this bound in `test`
-
-error[E0277]: `std::rc::Weak<i32>` cannot be shared between threads safely
- --> $DIR/not-sync.rs:15:12
- |
-LL | test::<Weak<i32>>();
- | ^^^^^^^^^ `std::rc::Weak<i32>` cannot be shared between threads safely
- |
- = help: the trait `Sync` is not implemented for `std::rc::Weak<i32>`
-note: required by a bound in `test`
- --> $DIR/not-sync.rs:5:12
- |
-LL | fn test<T: Sync>() {}
- | ^^^^ required by this bound in `test`
-
-error[E0277]: `std::sync::mpsc::Receiver<i32>` cannot be shared between threads safely
- --> $DIR/not-sync.rs:18:12
- |
-LL | test::<Receiver<i32>>();
- | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<i32>` cannot be shared between threads safely
- |
- = help: the trait `Sync` is not implemented for `std::sync::mpsc::Receiver<i32>`
-note: required by a bound in `test`
- --> $DIR/not-sync.rs:5:12
- |
-LL | fn test<T: Sync>() {}
- | ^^^^ required by this bound in `test`
-
-error[E0277]: `Sender<i32>` cannot be shared between threads safely
- --> $DIR/not-sync.rs:20:12
- |
-LL | test::<Sender<i32>>();
- | ^^^^^^^^^^^ `Sender<i32>` cannot be shared between threads safely
- |
- = help: the trait `Sync` is not implemented for `Sender<i32>`
-note: required by a bound in `test`
- --> $DIR/not-sync.rs:5:12
- |
-LL | fn test<T: Sync>() {}
- | ^^^^ required by this bound in `test`
-
-error: aborting due to 6 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
| required by a bound introduced by this call
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
-note: required by `Index::index`
- --> $DIR/multiple-impls.rs:12:5
- |
-LL | fn index(&self, index: Idx) -> &Self::Output;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
--> $DIR/multiple-impls.rs:36:18
| required by a bound introduced by this call
|
= help: the trait `Index<Foo<u32>>` is not implemented for `[i32]`
-note: required by `Index::index`
- --> $DIR/multiple-impls.rs:12:5
- |
-LL | fn index(&self, index: Idx) -> &Self::Output;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
--> $DIR/multiple-impls.rs:39:18
| required by a bound introduced by this call
|
= help: the trait `Index<Bar<u32>>` is not implemented for `[i32]`
-note: required by `Index::index`
- --> $DIR/multiple-impls.rs:12:5
- |
-LL | fn index(&self, index: Idx) -> &Self::Output;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
--> $DIR/multiple-impls.rs:33:5
| required by a bound introduced by this call
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
-note: required by `Index::index`
- --> $DIR/on-impl.rs:9:5
- |
-LL | fn index(&self, index: Idx) -> &Self::Output;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
--> $DIR/on-impl.rs:22:5
+++ /dev/null
-// run-pass
-// Testing guarantees provided by once functions.
-
-
-
-use std::sync::Arc;
-
-fn foo<F:FnOnce()>(blk: F) {
- blk();
-}
-
-pub fn main() {
- let x = Arc::new(true);
- foo(move|| {
- assert!(*x);
- drop(x);
- });
-}
+++ /dev/null
-// run-pass
-// Testcase for issue #130, operator associativity.
-
-pub fn main() { assert_eq!(3 * 5 / 2, 7); }
+++ /dev/null
-// run-pass
-// Test that we can overload the `+` operator for points so that two
-// points can be added, and a point can be added to an integer.
-
-use std::ops;
-
-#[derive(Debug,PartialEq,Eq)]
-struct Point {
- x: isize,
- y: isize
-}
-
-impl ops::Add for Point {
- type Output = Point;
-
- fn add(self, other: Point) -> Point {
- Point {x: self.x + other.x, y: self.y + other.y}
- }
-}
-
-impl ops::Add<isize> for Point {
- type Output = Point;
-
- fn add(self, other: isize) -> Point {
- Point {x: self.x + other,
- y: self.y + other}
- }
-}
-
-pub fn main() {
- let mut p = Point {x: 10, y: 20};
- p = p + Point {x: 101, y: 102};
- assert_eq!(p, Point {x: 111, y: 122});
- p = p + 1;
- assert_eq!(p, Point {x: 112, y: 123});
-}
+++ /dev/null
-// run-pass
-
-#![allow(unused_variables)]
-use std::cmp;
-use std::ops;
-
-#[derive(Copy, Clone, Debug)]
-struct Point {
- x: isize,
- y: isize
-}
-
-impl ops::Add for Point {
- type Output = Point;
-
- fn add(self, other: Point) -> Point {
- Point {x: self.x + other.x, y: self.y + other.y}
- }
-}
-
-impl ops::Sub for Point {
- type Output = Point;
-
- fn sub(self, other: Point) -> Point {
- Point {x: self.x - other.x, y: self.y - other.y}
- }
-}
-
-impl ops::Neg for Point {
- type Output = Point;
-
- fn neg(self) -> Point {
- Point {x: -self.x, y: -self.y}
- }
-}
-
-impl ops::Not for Point {
- type Output = Point;
-
- fn not(self) -> Point {
- Point {x: !self.x, y: !self.y }
- }
-}
-
-impl ops::Index<bool> for Point {
- type Output = isize;
-
- fn index(&self, x: bool) -> &isize {
- if x {
- &self.x
- } else {
- &self.y
- }
- }
-}
-
-impl cmp::PartialEq for Point {
- fn eq(&self, other: &Point) -> bool {
- (*self).x == (*other).x && (*self).y == (*other).y
- }
- fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
-}
-
-pub fn main() {
- let mut p = Point {x: 10, y: 20};
- p = p + Point {x: 101, y: 102};
- p = p - Point {x: 100, y: 100};
- assert_eq!(p + Point {x: 5, y: 5}, Point {x: 16, y: 27});
- assert_eq!(-p, Point {x: -11, y: -22});
- assert_eq!(p[true], 11);
- assert_eq!(p[false], 22);
-
- let q = !p;
- assert_eq!(q.x, !(p.x));
- assert_eq!(q.y, !(p.y));
-
- // Issue #1733
- result(p[true]);
-}
-
-fn result(i: isize) { }
+++ /dev/null
-#![feature(fn_traits, unboxed_closures)]
-
-use std::ops::FnMut;
-
-struct S {
- x: isize,
- y: isize,
-}
-
-impl FnMut<isize> for S {
- extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
- self.x + self.y + z
- }
- //~^^^ ERROR functions with the "rust-call" ABI must take a single non-self argument
-}
-
-impl FnOnce<isize> for S {
- type Output = isize;
- extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) }
- //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument
-}
-
-fn main() {
- let mut s = S {
- x: 1,
- y: 2,
- };
- drop(s(3)) //~ ERROR cannot use call notation
-}
+++ /dev/null
-error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple
- --> $DIR/overloaded-calls-nontuple.rs:11:5
- |
-LL | extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple
- --> $DIR/overloaded-calls-nontuple.rs:19:5
- |
-LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit
- --> $DIR/overloaded-calls-nontuple.rs:28:10
- |
-LL | drop(s(3))
- | ^^^^
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0059`.
--- /dev/null
+#![feature(fn_traits, unboxed_closures)]
+
+use std::ops::FnMut;
+
+struct S {
+ x: isize,
+ y: isize,
+}
+
+impl FnMut<isize> for S {
+ extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
+ self.x + self.y + z
+ }
+ //~^^^ ERROR functions with the "rust-call" ABI must take a single non-self argument
+}
+
+impl FnOnce<isize> for S {
+ type Output = isize;
+ extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) }
+ //~^ ERROR functions with the "rust-call" ABI must take a single non-self argument
+}
+
+fn main() {
+ let mut s = S {
+ x: 1,
+ y: 2,
+ };
+ drop(s(3)) //~ ERROR cannot use call notation
+}
--- /dev/null
+error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple
+ --> $DIR/overloaded-calls-nontuple.rs:11:5
+ |
+LL | extern "rust-call" fn call_mut(&mut self, z: isize) -> isize {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: functions with the "rust-call" ABI must take a single non-self argument that is a tuple
+ --> $DIR/overloaded-calls-nontuple.rs:19:5
+ |
+LL | extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit
+ --> $DIR/overloaded-calls-nontuple.rs:28:10
+ |
+LL | drop(s(3))
+ | ^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0059`.
--- /dev/null
+fn foo<#[attr]>() {} //~ ERROR attribute without generic parameters
+
+fn main() {}
--- /dev/null
+error: attribute without generic parameters
+ --> $DIR/attribute-with-no-generics-in-parameter-list.rs:1:8
+ |
+LL | fn foo<#[attr]>() {}
+ | ^^^^^^^ attributes are only permitted when preceding parameters
+
+error: aborting due to previous error
+
+++ /dev/null
-// include file for issue-21146.rs
-
-parse_error
+++ /dev/null
-// force-host
-// no-prefer-dynamic
-
-#![crate_type = "proc-macro"]
-
-extern crate proc_macro;
-
-use proc_macro::TokenStream;
-
-#[proc_macro_derive(ICE)]
-pub fn derive(_: TokenStream) -> TokenStream {
- r#"#[allow(missing_docs)] struct X { }"#.parse().unwrap()
-}
--- /dev/null
+type A0 = dyn;
+//~^ ERROR cannot find type `dyn` in this scope
+type A1 = dyn::dyn;
+//~^ ERROR use of undeclared crate or module `dyn`
+type A2 = dyn<dyn, dyn>;
+//~^ ERROR cannot find type `dyn` in this scope
+//~| ERROR cannot find type `dyn` in this scope
+//~| ERROR cannot find type `dyn` in this scope
+type A3 = dyn<<dyn as dyn>::dyn>;
+//~^ ERROR cannot find type `dyn` in this scope
+//~| ERROR cannot find type `dyn` in this scope
+//~| ERROR use of undeclared crate or module `dyn`
+
+fn main() {}
--- /dev/null
+error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
+ --> $DIR/dyn-trait-compatibility.rs:3:11
+ |
+LL | type A1 = dyn::dyn;
+ | ^^^ use of undeclared crate or module `dyn`
+
+error[E0433]: failed to resolve: use of undeclared crate or module `dyn`
+ --> $DIR/dyn-trait-compatibility.rs:9:23
+ |
+LL | type A3 = dyn<<dyn as dyn>::dyn>;
+ | ^^^ use of undeclared crate or module `dyn`
+
+error[E0412]: cannot find type `dyn` in this scope
+ --> $DIR/dyn-trait-compatibility.rs:1:11
+ |
+LL | type A0 = dyn;
+ | ^^^ not found in this scope
+
+error[E0412]: cannot find type `dyn` in this scope
+ --> $DIR/dyn-trait-compatibility.rs:5:11
+ |
+LL | type A2 = dyn<dyn, dyn>;
+ | ^^^ not found in this scope
+
+error[E0412]: cannot find type `dyn` in this scope
+ --> $DIR/dyn-trait-compatibility.rs:5:15
+ |
+LL | type A2 = dyn<dyn, dyn>;
+ | - ^^^ not found in this scope
+ | |
+ | help: you might be missing a type parameter: `<dyn>`
+
+error[E0412]: cannot find type `dyn` in this scope
+ --> $DIR/dyn-trait-compatibility.rs:5:20
+ |
+LL | type A2 = dyn<dyn, dyn>;
+ | - ^^^ not found in this scope
+ | |
+ | help: you might be missing a type parameter: `<dyn>`
+
+error[E0412]: cannot find type `dyn` in this scope
+ --> $DIR/dyn-trait-compatibility.rs:9:11
+ |
+LL | type A3 = dyn<<dyn as dyn>::dyn>;
+ | ^^^ not found in this scope
+
+error[E0412]: cannot find type `dyn` in this scope
+ --> $DIR/dyn-trait-compatibility.rs:9:16
+ |
+LL | type A3 = dyn<<dyn as dyn>::dyn>;
+ | - ^^^ not found in this scope
+ | |
+ | help: you might be missing a type parameter: `<dyn>`
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0412, E0433.
+For more information about an error, try `rustc --explain E0412`.
|
= note: while checking the return type of the `async fn`
= note: expected fn pointer `fn()`
- found fn pointer `fn() -> impl Future`
+ found fn pointer `fn() -> impl Future<Output = ()>`
error[E0053]: method `ft5` has an incompatible type for trait
--> $DIR/fn-header-semantic-fail.rs:33:48
|
= note: while checking the return type of the `async fn`
= note: expected fn pointer `unsafe extern "C" fn()`
- found fn pointer `unsafe extern "C" fn() -> impl Future`
+ found fn pointer `unsafe extern "C" fn() -> impl Future<Output = ()>`
error: aborting due to 20 previous errors
+++ /dev/null
-// run-rustfix
-
-pub struct A { pub foo: isize }
-
-fn a() -> A { panic!() }
-
-fn main() {
- let A { .. } = a(); //~ ERROR: expected `}`
-}
+++ /dev/null
-// run-rustfix
-
-pub struct A { pub foo: isize }
-
-fn a() -> A { panic!() }
-
-fn main() {
- let A { .., } = a(); //~ ERROR: expected `}`
-}
+++ /dev/null
-error: expected `}`, found `,`
- --> $DIR/issue-10392-2.rs:8:15
- |
-LL | let A { .., } = a();
- | --^
- | | |
- | | expected `}`
- | | help: remove this comma
- | `..` must be at the end and cannot have a trailing comma
-
-error: aborting due to previous error
-
+++ /dev/null
-struct A { foo: isize }
-
-fn a() -> A { panic!() }
-
-fn main() {
- let A { , } = a(); //~ ERROR expected ident
-}
+++ /dev/null
-error: expected identifier, found `,`
- --> $DIR/issue-10392.rs:6:13
- |
-LL | let A { , } = a();
- | - ^ expected identifier
- | |
- | while parsing the fields for this pattern
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Obj {
- //~^ NOTE: unclosed delimiter
- member: usize
-)
-//~^ ERROR mismatched closing delimiter
-//~| NOTE mismatched closing delimiter
-
-fn main() {}
+++ /dev/null
-error: mismatched closing delimiter: `)`
- --> $DIR/issue-10636-1.rs:1:12
- |
-LL | struct Obj {
- | ^ unclosed delimiter
-...
-LL | )
- | ^ mismatched closing delimiter
-
-error: aborting due to previous error
-
+++ /dev/null
-// FIXME(31528) we emit a bunch of silly errors here due to continuing past the
-// first one. This would be easy-ish to address by better recovery in tokenisation.
-
-pub fn trace_option(option: Option<isize>) {
- option.map(|some| 42;
- //~^ ERROR: expected one of
-
-}
-//~^ ERROR: expected expression, found `)`
-
-fn main() {}
+++ /dev/null
-error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
- --> $DIR/issue-10636-2.rs:5:15
- |
-LL | option.map(|some| 42;
- | ^ ^ help: `)` may belong here
- | |
- | unclosed delimiter
-
-error: expected expression, found `)`
- --> $DIR/issue-10636-2.rs:8:1
- |
-LL | }
- | ^ expected expression
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-fn main() {
- if true {
- } else if { //~ ERROR missing condition
- //~^ ERROR mismatched types
- } else {
- }
-}
-
-fn foo() {
- if true {
- } else if { //~ ERROR missing condition
- //~^ ERROR mismatched types
- }
- bar();
-}
-
-fn bar() {}
+++ /dev/null
-error: missing condition for `if` expression
- --> $DIR/issue-13483.rs:3:14
- |
-LL | } else if {
- | ^ expected if condition here
-
-error: missing condition for `if` expression
- --> $DIR/issue-13483.rs:11:14
- |
-LL | } else if {
- | ^ expected if condition here
-
-error[E0308]: mismatched types
- --> $DIR/issue-13483.rs:3:15
- |
-LL | } else if {
- | _______________^
-LL | |
-LL | | } else {
- | |_____^ expected `bool`, found `()`
-
-error[E0308]: mismatched types
- --> $DIR/issue-13483.rs:11:15
- |
-LL | } else if {
- | _______________^
-LL | |
-LL | | }
- | |_____^ expected `bool`, found `()`
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-enum X<'a, T, 'b> {
-//~^ ERROR lifetime parameters must be declared prior to type parameters
- A(&'a &'b T)
-}
-
-fn main() {}
+++ /dev/null
-error: lifetime parameters must be declared prior to type parameters
- --> $DIR/issue-14303-enum.rs:1:15
- |
-LL | enum X<'a, T, 'b> {
- | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
-
-error: aborting due to previous error
-
+++ /dev/null
-fn foo<'a, T, 'b>(x: &'a T) {}
-//~^ ERROR lifetime parameters must be declared prior to type parameters
-
-fn main() {}
+++ /dev/null
-error: lifetime parameters must be declared prior to type parameters
- --> $DIR/issue-14303-fn-def.rs:1:15
- |
-LL | fn foo<'a, T, 'b>(x: &'a T) {}
- | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
-
-error: aborting due to previous error
-
+++ /dev/null
-error[E0747]: type provided when a lifetime was expected
- --> $DIR/issue-14303-fncall.rs:16:26
- |
-LL | .collect::<Vec<S<_, 'a>>>();
- | ^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0747`.
+++ /dev/null
-error[E0747]: inferred provided when a lifetime was expected
- --> $DIR/issue-14303-fncall.rs:16:26
- |
-LL | .collect::<Vec<S<_, 'a>>>();
- | ^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0747`.
+++ /dev/null
-// revisions: full generic_arg
-// compile-flags: -Zborrowck=mir
-// can't run rustfix because it doesn't handle multipart suggestions correctly
-// we need the above to avoid ast borrowck failure in recovered code
-#![cfg_attr(generic_arg, feature(generic_arg_infer))]
-
-
-struct S<'a, T> {
- a: &'a T,
- b: &'a T,
-}
-
-fn foo<'a, 'b>(start: &'a usize, end: &'a usize) {
- let _x = (*start..*end)
- .map(|x| S { a: start, b: end })
- .collect::<Vec<S<_, 'a>>>();
- //[generic_arg]~^ ERROR inferred provided when a lifetime was expected
- //[full]~^^ ERROR type provided when a lifetime was expected
-}
-
-fn main() {}
+++ /dev/null
-struct X<T>(T);
-
-impl<'a, T, 'b> X<T> {}
-//~^ ERROR lifetime parameters must be declared prior to type parameters
-
-fn main() {}
+++ /dev/null
-error: lifetime parameters must be declared prior to type parameters
- --> $DIR/issue-14303-impl.rs:3:13
- |
-LL | impl<'a, T, 'b> X<T> {}
- | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
-
-error: aborting due to previous error
-
+++ /dev/null
-mod foo {
- pub struct X<'a, 'b, 'c, T> {
- a: &'a str,
- b: &'b str,
- c: &'c str,
- t: T,
- }
-}
-
-fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
-//~^ ERROR type provided when a lifetime was expected
-
-fn main() {}
+++ /dev/null
-error[E0747]: type provided when a lifetime was expected
- --> $DIR/issue-14303-path.rs:10:37
- |
-LL | fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
- | ^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0747`.
+++ /dev/null
-struct X<'a, T, 'b> {
-//~^ ERROR lifetime parameters must be declared prior to type parameters
- x: &'a &'b T
-}
-
-fn main() {}
+++ /dev/null
-error: lifetime parameters must be declared prior to type parameters
- --> $DIR/issue-14303-struct.rs:1:17
- |
-LL | struct X<'a, T, 'b> {
- | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
-
-error: aborting due to previous error
-
+++ /dev/null
-trait Foo<'a, T, 'b> {}
-//~^ ERROR lifetime parameters must be declared prior to type parameters
-
-fn main() {}
+++ /dev/null
-error: lifetime parameters must be declared prior to type parameters
- --> $DIR/issue-14303-trait.rs:1:18
- |
-LL | trait Foo<'a, T, 'b> {}
- | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {
- let ref
- (); //~ ERROR expected identifier, found `(`
-}
+++ /dev/null
-error: expected identifier, found `(`
- --> $DIR/issue-15914.rs:3:9
- |
-LL | ();
- | ^ expected identifier
-
-error: aborting due to previous error
-
+++ /dev/null
-use std::io;
-
-fn main(){
- let x: io::Result<()> = Ok(());
- match x {
- Err(ref e) if e.kind == io::EndOfFile {
- //~^ NOTE while parsing this struct
- return
- //~^ ERROR expected identifier, found keyword `return`
- //~| NOTE expected identifier, found keyword
- }
- //~^ NOTE expected one of `.`, `=>`, `?`, or an operator
- _ => {}
- //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
- //~| NOTE unexpected token
- }
-}
+++ /dev/null
-error: expected identifier, found keyword `return`
- --> $DIR/issue-15980.rs:8:13
- |
-LL | Err(ref e) if e.kind == io::EndOfFile {
- | ------------- while parsing this struct
-LL |
-LL | return
- | ^^^^^^ expected identifier, found keyword
- |
-help: you can escape reserved keywords to use them as identifiers
- |
-LL | r#return
- |
-
-error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
- --> $DIR/issue-15980.rs:13:9
- |
-LL | }
- | - expected one of `.`, `=>`, `?`, or an operator
-LL |
-LL | _ => {}
- | ^ unexpected token
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-mod blade_runner {
- #vec[doc( //~ ERROR expected one of `!` or `[`, found `vec`
- brief = "Blade Runner is probably the best movie ever",
- desc = "I like that in the world of Blade Runner it is always
- raining, and that it's always night time. And Aliens
- was also a really good movie.
-
- Alien 3 was crap though."
- )]
-}
+++ /dev/null
-error: expected one of `!` or `[`, found `vec`
- --> $DIR/issue-1655.rs:2:6
- |
-LL | #vec[doc(
- | ^^^ expected one of `!` or `[`
-
-error: aborting due to previous error
-
+++ /dev/null
-enum X {
- A = 3,
- //~^ ERROR custom discriminant values are not allowed in enums with tuple or struct variants
- B(usize)
-}
-
-fn main() {}
+++ /dev/null
-error[E0658]: custom discriminant values are not allowed in enums with tuple or struct variants
- --> $DIR/issue-17383.rs:2:9
- |
-LL | A = 3,
- | ^ disallowed custom discriminant
-LL |
-LL | B(usize)
- | -------- tuple variant defined here
- |
- = note: see issue #60553 <https://github.com/rust-lang/rust/issues/60553> for more information
- = help: add `#![feature(arbitrary_enum_discriminant)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
+++ /dev/null
-const
-mut //~ ERROR: const globals cannot be mutable
-//~^^ HELP you might want to declare a static instead
-FOO: usize = 3;
-
-fn main() {
-}
+++ /dev/null
-error: const globals cannot be mutable
- --> $DIR/issue-17718-const-mut.rs:2:1
- |
-LL | const
- | ----- help: you might want to declare a static instead: `static`
-LL | mut
- | ^^^ cannot be mutable
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found keyword `where`
-
-fn main() {}
+++ /dev/null
-error: expected item, found keyword `where`
- --> $DIR/issue-17904-2.rs:1:24
- |
-LL | struct Bar<T> { x: T } where T: Copy
- | ^^^^^ expected item
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax.
-struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well.
-struct Baz<U>(U) where U: Eq; // This rightfully signals no error as well.
-struct Foo<T> where T: Copy, (T); //~ ERROR expected one of `:`, `==`, or `=`, found `;`
-
-fn main() {}
+++ /dev/null
-error: expected one of `:`, `==`, or `=`, found `;`
- --> $DIR/issue-17904.rs:4:33
- |
-LL | struct Foo<T> where T: Copy, (T);
- | ^ expected one of `:`, `==`, or `=`
-
-error: aborting due to previous error
-
+++ /dev/null
-fn log(a: i32, b: i32) {}
-
-fn main() {
- let error = 42;
- log(error, 0b);
- //~^ ERROR no valid digits found for number
-}
+++ /dev/null
-error[E0768]: no valid digits found for number
- --> $DIR/issue-1802-1.rs:5:16
- |
-LL | log(error, 0b);
- | ^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0768`.
+++ /dev/null
-fn log(a: i32, b: i32) {}
-
-fn main() {
- let error = 42;
- log(error, 0b);
- //~^ ERROR no valid digits found for number
-}
+++ /dev/null
-error[E0768]: no valid digits found for number
- --> $DIR/issue-1802-2.rs:5:16
- |
-LL | log(error, 0b);
- | ^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0768`.
+++ /dev/null
-fn main() { // we don't complain about the return type being `{integer}`
- let t = (42, 42);
- t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
-}
-
-fn foo() -> usize { // we don't complain about the return type being unit
- let t = (42, 42);
- t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
- 42;
-}
+++ /dev/null
-error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
- --> $DIR/issue-19096.rs:3:8
- |
-LL | t.0::<isize>;
- | ^^ expected one of `.`, `;`, `?`, `}`, or an operator
-
-error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
- --> $DIR/issue-19096.rs:8:8
- |
-LL | t.0::<isize>;
- | ^^ expected one of `.`, `;`, `?`, `}`, or an operator
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-trait T {
- extern "Rust" unsafe fn foo();
- //~^ ERROR expected `{`, found keyword `unsafe`
-}
-
-fn main() {}
+++ /dev/null
-error: expected `{`, found keyword `unsafe`
- --> $DIR/issue-19398.rs:2:19
- |
-LL | trait T {
- | - while parsing this item list starting here
-LL | extern "Rust" unsafe fn foo();
- | ^^^^^^ expected `{`
-LL |
-LL | }
- | - the item list ends here
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-
-
-type Type_1_<'a, T> = &'a T;
-
-
-type Type_1<'a T> = &'a T; //~ error: expected one of `,`, `:`, or `>`, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+++ /dev/null
-error: expected one of `,`, `:`, or `>`, found `T`
- --> $DIR/issue-20616-1.rs:9:16
- |
-LL | type Type_1<'a T> = &'a T;
- | ^ expected one of `,`, `:`, or `>`
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,`, `:`, `=`, or `>`, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+++ /dev/null
-error: expected one of `,`, `:`, `=`, or `>`, found `(`
- --> $DIR/issue-20616-2.rs:12:31
- |
-LL | type Type_2 = Type_1_<'static ()>;
- | ^ expected one of `,`, `:`, `=`, or `>`
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-type Type_3<T> = Box<T,,>;
-//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+++ /dev/null
-error: expected one of `>`, a const expression, lifetime, or type, found `,`
- --> $DIR/issue-20616-3.rs:13:24
- |
-LL | type Type_3<T> = Box<T,,>;
- | ^ expected one of `>`, a const expression, lifetime, or type
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-type Type_4<T> = Type_1_<'static,, T>;
-//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+++ /dev/null
-error: expected one of `>`, a const expression, lifetime, or type, found `,`
- --> $DIR/issue-20616-4.rs:16:34
- |
-LL | type Type_4<T> = Type_1_<'static,, T>;
- | ^ expected one of `>`, a const expression, lifetime, or type
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-type Type_5<'a> = Type_1_<'a, (),,>;
-//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+++ /dev/null
-error: expected one of `>`, a const expression, lifetime, or type, found `,`
- --> $DIR/issue-20616-5.rs:22:34
- |
-LL | type Type_5<'a> = Type_1_<'a, (),,>;
- | ^ expected one of `>`, a const expression, lifetime, or type
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-type Type_6 = Type_5_<'a,,>;
-//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+++ /dev/null
-error: expected one of `>`, a const expression, lifetime, or type, found `,`
- --> $DIR/issue-20616-6.rs:25:26
- |
-LL | type Type_6 = Type_5_<'a,,>;
- | ^ expected one of `>`, a const expression, lifetime, or type
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-type Type_7 = Box<(),,>;
-//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
+++ /dev/null
-error: expected one of `>`, a const expression, lifetime, or type, found `,`
- --> $DIR/issue-20616-7.rs:28:22
- |
-LL | type Type_7 = Box<(),,>;
- | ^ expected one of `>`, a const expression, lifetime, or type
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-type Type_8<'a,,> = &'a ();
-//~^ error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
-
-
-//type Type_9<T,,> = Box<T>; // error: expected identifier, found `,`
+++ /dev/null
-error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
- --> $DIR/issue-20616-8.rs:31:16
- |
-LL | type Type_8<'a,,> = &'a ();
- | ^ expected one of `#`, `>`, `const`, identifier, or lifetime
-
-error: aborting due to previous error
-
+++ /dev/null
-// We need all these 9 issue-20616-N.rs files
-// because we can only catch one parsing error at a time
-
-type Type_1_<'a, T> = &'a T;
-
-
-//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
-
-
-//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
-
-
-//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
-
-
-//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
-
-
-type Type_5_<'a> = Type_1_<'a, ()>;
-
-
-//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
-
-
-//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
-
-
-//type Type_7 = Box<(),,>; // error: expected type, found `,`
-
-
-//type Type_8<'a,,> = &'a (); // error: expected identifier, found `,`
-
-
-type Type_9<T,,> = Box<T>;
-//~^ error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
+++ /dev/null
-error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
- --> $DIR/issue-20616-9.rs:34:15
- |
-LL | type Type_9<T,,> = Box<T>;
- | ^ expected one of `#`, `>`, `const`, identifier, or lifetime
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Foo;
-
-impl Foo {
- fn foo() {}
-
- #[stable(feature = "rust1", since = "1.0.0")]
- //~^ ERROR expected item after attributes
-}
-
-fn main() {}
+++ /dev/null
-error: expected item after attributes
- --> $DIR/issue-20711-2.rs:6:5
- |
-LL | impl Foo {
- | - while parsing this item list starting here
-...
-LL | #[stable(feature = "rust1", since = "1.0.0")]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | }
- | - the item list ends here
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Foo;
-
-impl Foo {
- #[stable(feature = "rust1", since = "1.0.0")]
- //~^ ERROR expected item after attributes
-}
-
-fn main() {}
+++ /dev/null
-error: expected item after attributes
- --> $DIR/issue-20711.rs:4:5
- |
-LL | impl Foo {
- | - while parsing this item list starting here
-LL | #[stable(feature = "rust1", since = "1.0.0")]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | }
- | - the item list ends here
-
-error: aborting due to previous error
-
+++ /dev/null
-// error-pattern: expected one of `!` or `::`, found `<eof>`
-include!("auxiliary/issue-21146-inc.rs");
-fn main() {}
+++ /dev/null
-error: expected one of `!` or `::`, found `<eof>`
- --> $DIR/auxiliary/issue-21146-inc.rs:3:1
- |
-LL | parse_error
- | ^^^^^^^^^^^ expected one of `!` or `::`
-
-error: aborting due to previous error
-
+++ /dev/null
-trait MyTrait<T>: Iterator {
- Item = T;
- //~^ ERROR expected one of `!` or `::`, found `=`
-}
-
-fn main() {}
+++ /dev/null
-error: expected one of `!` or `::`, found `=`
- --> $DIR/issue-21153.rs:2:10
- |
-LL | trait MyTrait<T>: Iterator {
- | - while parsing this item list starting here
-LL | Item = T;
- | ^ expected one of `!` or `::`
-LL |
-LL | }
- | - the item list ends here
-
-error: aborting due to previous error
-
+++ /dev/null
-// run-pass
-#![allow(unused_imports, overlapping_range_endpoints)]
-// pretty-expanded FIXME #23616
-
-use m::{START, END};
-
-fn main() {
- match 42 {
- m::START..=m::END => {},
- 0..=m::END => {},
- m::START..=59 => {},
- _ => {},
- }
-}
-
-mod m {
- pub const START: u32 = 4;
- pub const END: u32 = 14;
-}
+++ /dev/null
-fn main() {
- let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
- where F: Fn() -> i32
- {
- let x = f();
- println!("Y {}",x);
- return x;
- };
-
- caller(bar_handler);
-}
-
-fn bar_handler() -> i32 {
- 5
-}
+++ /dev/null
-error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
- --> $DIR/issue-22647.rs:2:15
- |
-LL | let caller<F> = |f: F|
- | ^ expected one of `:`, `;`, `=`, `@`, or `|`
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Foo<B> {
- buffer: B
-}
-
-fn bar() {
- let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
-}
-
-fn main() {}
+++ /dev/null
-error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
- --> $DIR/issue-22712.rs:6:12
- |
-LL | let Foo<Vec<u8>>
- | ^ expected one of `:`, `;`, `=`, `@`, or `|`
-
-error: aborting due to previous error
-
+++ /dev/null
-static foo: isize = 2; } //~ ERROR unexpected closing delimiter:
+++ /dev/null
-error: unexpected closing delimiter: `}`
- --> $DIR/issue-2354-1.rs:1:24
- |
-LL | static foo: isize = 2; }
- | ^ unexpected closing delimiter
-
-error: aborting due to previous error
-
+++ /dev/null
-fn foo() { //~ NOTE unclosed delimiter
- match Some(10) {
- //~^ NOTE this delimiter might not be properly closed...
- Some(y) => { panic!(); }
- None => { panic!(); }
-}
-//~^ NOTE ...as it matches this but it has different indentation
-
-fn bar() {
- let mut i = 0;
- while (i < 1000) {}
-}
-
-fn main() {}
-//~ ERROR this file contains an unclosed delimiter
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-2354.rs:15:52
- |
-LL | fn foo() {
- | - unclosed delimiter
-LL | match Some(10) {
- | - this delimiter might not be properly closed...
-...
-LL | }
- | - ...as it matches this but it has different indentation
-...
-LL |
- | ^
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {
- let _ = b"\u{a66e}";
- //~^ ERROR unicode escape in byte string
-
- let _ = b'\u{a66e}';
- //~^ ERROR unicode escape in byte string
-
- let _ = b'\u';
- //~^ ERROR incorrect unicode escape sequence
-
- let _ = b'\x5';
- //~^ ERROR numeric character escape is too short
-
- let _ = b'\xxy';
- //~^ ERROR invalid character in numeric character escape: `x`
-
- let _ = '\x5';
- //~^ ERROR numeric character escape is too short
-
- let _ = '\xxy';
- //~^ ERROR invalid character in numeric character escape: `x`
-
- let _ = b"\u{a4a4} \xf \u";
- //~^ ERROR unicode escape in byte string
- //~^^ ERROR invalid character in numeric character escape: ` `
- //~^^^ ERROR incorrect unicode escape sequence
-
- let _ = "\xf \u";
- //~^ ERROR invalid character in numeric character escape: ` `
- //~^^ ERROR incorrect unicode escape sequence
-
- let _ = "\u8f";
- //~^ ERROR incorrect unicode escape sequence
-}
+++ /dev/null
-error: unicode escape in byte string
- --> $DIR/issue-23620-invalid-escapes.rs:2:15
- |
-LL | let _ = b"\u{a66e}";
- | ^^^^^^^^ unicode escape in byte string
- |
- = help: unicode escape sequences cannot be used as a byte or in a byte string
-
-error: unicode escape in byte string
- --> $DIR/issue-23620-invalid-escapes.rs:5:15
- |
-LL | let _ = b'\u{a66e}';
- | ^^^^^^^^ unicode escape in byte string
- |
- = help: unicode escape sequences cannot be used as a byte or in a byte string
-
-error: incorrect unicode escape sequence
- --> $DIR/issue-23620-invalid-escapes.rs:8:15
- |
-LL | let _ = b'\u';
- | ^^ incorrect unicode escape sequence
- |
- = help: format of unicode escape sequences is `\u{...}`
-
-error: numeric character escape is too short
- --> $DIR/issue-23620-invalid-escapes.rs:11:15
- |
-LL | let _ = b'\x5';
- | ^^^
-
-error: invalid character in numeric character escape: `x`
- --> $DIR/issue-23620-invalid-escapes.rs:14:17
- |
-LL | let _ = b'\xxy';
- | ^ invalid character in numeric character escape
-
-error: numeric character escape is too short
- --> $DIR/issue-23620-invalid-escapes.rs:17:14
- |
-LL | let _ = '\x5';
- | ^^^
-
-error: invalid character in numeric character escape: `x`
- --> $DIR/issue-23620-invalid-escapes.rs:20:16
- |
-LL | let _ = '\xxy';
- | ^ invalid character in numeric character escape
-
-error: unicode escape in byte string
- --> $DIR/issue-23620-invalid-escapes.rs:23:15
- |
-LL | let _ = b"\u{a4a4} \xf \u";
- | ^^^^^^^^ unicode escape in byte string
- |
- = help: unicode escape sequences cannot be used as a byte or in a byte string
-
-error: invalid character in numeric character escape: ` `
- --> $DIR/issue-23620-invalid-escapes.rs:23:27
- |
-LL | let _ = b"\u{a4a4} \xf \u";
- | ^ invalid character in numeric character escape
-
-error: incorrect unicode escape sequence
- --> $DIR/issue-23620-invalid-escapes.rs:23:28
- |
-LL | let _ = b"\u{a4a4} \xf \u";
- | ^^ incorrect unicode escape sequence
- |
- = help: format of unicode escape sequences is `\u{...}`
-
-error: invalid character in numeric character escape: ` `
- --> $DIR/issue-23620-invalid-escapes.rs:28:17
- |
-LL | let _ = "\xf \u";
- | ^ invalid character in numeric character escape
-
-error: incorrect unicode escape sequence
- --> $DIR/issue-23620-invalid-escapes.rs:28:18
- |
-LL | let _ = "\xf \u";
- | ^^ incorrect unicode escape sequence
- |
- = help: format of unicode escape sequences is `\u{...}`
-
-error: incorrect unicode escape sequence
- --> $DIR/issue-23620-invalid-escapes.rs:32:14
- |
-LL | let _ = "\u8f";
- | ^^^-
- | |
- | help: format of unicode escape sequences uses braces: `\u{8f}`
-
-error: aborting due to 13 previous errors
-
+++ /dev/null
-fn main() {
- let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `[`
-}
+++ /dev/null
-error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[`
- --> $DIR/issue-24197.rs:2:12
- |
-LL | let buf[0] = 0;
- | ^ expected one of `:`, `;`, `=`, `@`, or `|`
-
-error: aborting due to previous error
-
+++ /dev/null
-static tmp : [&'static str; 2] = ["hello", "he"];
-
-fn main() {
- let z = "hello";
- match z {
- tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[`
- _ => {}
- }
-}
+++ /dev/null
-error: expected one of `=>`, `@`, `if`, or `|`, found `[`
- --> $DIR/issue-24375.rs:6:12
- |
-LL | tmp[0] => {}
- | ^ expected one of `=>`, `@`, `if`, or `|`
-
-error: aborting due to previous error
-
+++ /dev/null
-// Verify that '>' is not both expected and found at the same time, as it used
-// to happen in #24780. For example, following should be an error:
-// expected one of ..., `>`, ... found `>`.
-
-fn foo() -> Vec<usize>> { //~ ERROR expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
- Vec::new()
-}
-
-fn main() {}
+++ /dev/null
-error: expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
- --> $DIR/issue-24780.rs:5:23
- |
-LL | fn foo() -> Vec<usize>> {
- | ^ expected one of `!`, `+`, `::`, `;`, `where`, or `{`
-
-error: aborting due to previous error
-
+++ /dev/null
-trait A {}
-
-impl A .. {}
-//~^ ERROR missing `for` in a trait impl
-//~| ERROR `impl Trait for .. {}` is an obsolete syntax
-
-impl A usize {}
-//~^ ERROR missing `for` in a trait impl
-
-fn main() {}
+++ /dev/null
-error: missing `for` in a trait impl
- --> $DIR/issue-27255.rs:3:7
- |
-LL | impl A .. {}
- | ^ help: add `for` here
-
-error: missing `for` in a trait impl
- --> $DIR/issue-27255.rs:7:7
- |
-LL | impl A usize {}
- | ^^^^^^ help: add `for` here
-
-error: `impl Trait for .. {}` is an obsolete syntax
- --> $DIR/issue-27255.rs:3:1
- |
-LL | impl A .. {}
- | ^^^^^^^^^^^^
- |
- = help: use `auto trait Trait {}` instead
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// run-rustfix
-#![allow(unused)]
-fn foo() { }
-
-/// Misplaced comment...
-//~^ ERROR expected outer doc comment
-fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function
-
-#[test] //~ ERROR an inner attribute is not permitted in this context
-fn baz() { } //~ NOTE the inner attribute doesn't annotate this function
-//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually
-
-/** Misplaced comment... */
-//~^ ERROR expected outer doc comment
-fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function
-
-fn main() { }
-
-// Misplaced comment...
-//~^ ERROR expected outer doc comment
-//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
-//~| NOTE other attributes here
-/* Misplaced comment... */
-//~^ ERROR expected outer doc comment
-//~| NOTE this doc comment doesn't document anything
-//~| ERROR expected item after doc comment
-//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
+++ /dev/null
-// run-rustfix
-#![allow(unused)]
-fn foo() { }
-
-//! Misplaced comment...
-//~^ ERROR expected outer doc comment
-fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function
-
-#![test] //~ ERROR an inner attribute is not permitted in this context
-fn baz() { } //~ NOTE the inner attribute doesn't annotate this function
-//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually
-
-/*! Misplaced comment... */
-//~^ ERROR expected outer doc comment
-fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function
-
-fn main() { }
-
-//! Misplaced comment...
-//~^ ERROR expected outer doc comment
-//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
-//~| NOTE other attributes here
-/*! Misplaced comment... */
-//~^ ERROR expected outer doc comment
-//~| NOTE this doc comment doesn't document anything
-//~| ERROR expected item after doc comment
-//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
+++ /dev/null
-error[E0753]: expected outer doc comment
- --> $DIR/issue-30318.rs:5:1
- |
-LL | //! Misplaced comment...
- | ^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | fn bar() { }
- | ------------ the inner doc comment doesn't annotate this function
- |
-help: to annotate the function, change the doc comment from inner to outer style
- |
-LL | /// Misplaced comment...
- | ~
-
-error: an inner attribute is not permitted in this context
- --> $DIR/issue-30318.rs:9:1
- |
-LL | #![test]
- | ^^^^^^^^
-LL | fn baz() { }
- | ------------ the inner attribute doesn't annotate this function
- |
- = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
-help: to annotate the function, change the attribute from inner to outer style
- |
-LL - #![test]
-LL + #[test]
- |
-
-error[E0753]: expected outer doc comment
- --> $DIR/issue-30318.rs:13:1
- |
-LL | /*! Misplaced comment... */
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | fn bat() { }
- | ------------ the inner doc comment doesn't annotate this function
- |
-help: to annotate the function, change the doc comment from inner to outer style
- |
-LL | /** Misplaced comment... */
- | ~
-
-error[E0753]: expected outer doc comment
- --> $DIR/issue-30318.rs:19:1
- |
-LL | //! Misplaced comment...
- | ^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
-help: you might have meant to write a regular comment
- |
-LL - //! Misplaced comment...
-LL + // Misplaced comment...
- |
-
-error[E0753]: expected outer doc comment
- --> $DIR/issue-30318.rs:23:1
- |
-LL | /*! Misplaced comment... */
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
-help: you might have meant to write a regular comment
- |
-LL - /*! Misplaced comment... */
-LL + /* Misplaced comment... */
- |
-
-error: expected item after doc comment
- --> $DIR/issue-30318.rs:23:1
- |
-LL | //! Misplaced comment...
- | ------------------------ other attributes here
-...
-LL | /*! Misplaced comment... */
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment doesn't document anything
-
-error: aborting due to 6 previous errors
-
-For more information about this error, try `rustc --explain E0753`.
+++ /dev/null
-// run-rustfix
-
-// Testing that semicolon tokens are printed correctly in errors
-
-fn main() {
- let _x = 3; //~ ERROR: expected `;`
-}
+++ /dev/null
-// run-rustfix
-
-// Testing that semicolon tokens are printed correctly in errors
-
-fn main() {
- let _x = 3 //~ ERROR: expected `;`
-}
+++ /dev/null
-error: expected `;`, found `}`
- --> $DIR/issue-3036.rs:6:15
- |
-LL | let _x = 3
- | ^ help: add `;` here
-LL | }
- | - unexpected token
-
-error: aborting due to previous error
-
+++ /dev/null
-// Test that error recovery in the parser to an EOF does not give an infinite
-// spew of errors.
-
-fn main() {
- let
-} //~ ERROR expected pattern, found `}`
+++ /dev/null
-error: expected pattern, found `}`
- --> $DIR/issue-31804.rs:6:1
- |
-LL | }
- | ^ expected pattern
-
-error: aborting due to previous error
-
+++ /dev/null
-trait Trait<T> { type Item; }
-
-pub fn test<W, I: Trait<Item=(), W> >() {}
-//~^ ERROR generic arguments must come before the first constraint
-
-fn main() { }
+++ /dev/null
-error: generic arguments must come before the first constraint
- --> $DIR/issue-32214.rs:3:34
- |
-LL | pub fn test<W, I: Trait<Item=(), W> >() {}
- | ------- ^ generic argument
- | |
- | constraint
- |
-help: move the constraint after the generic argument
- |
-LL | pub fn test<W, I: Trait<W, Item = ()> >() {}
- | ~~~~~~~~~~~~~~
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {}
-
-// This used to end up in an infite loop trying to bump past EOF.
-trait T { ... } //~ ERROR
+++ /dev/null
-error: non-item in item list
- --> $DIR/issue-32446.rs:4:11
- |
-LL | trait T { ... }
- | - ^^^ - item list ends here
- | | |
- | | non-item starts here
- | item list starts here
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {
- let a = 0;
- let _b = 0;
- let _ = 0;
- let mut b = 0;
- let mut _b = 0;
- let mut _ = 0;
- //~^ ERROR `mut` must be followed by a named binding
-}
+++ /dev/null
-error: `mut` must be followed by a named binding
- --> $DIR/issue-32501.rs:7:9
- |
-LL | let mut _ = 0;
- | ^^^^^ help: remove the `mut` prefix: `_`
- |
- = note: `mut` may be followed by `variable` and `variable @ pattern`
-
-error: aborting due to previous error
-
+++ /dev/null
-pub fn test() {
- foo(|_|) //~ ERROR expected expression, found `)`
-}
-
-fn main() { }
+++ /dev/null
-error: expected expression, found `)`
- --> $DIR/issue-32505.rs:2:12
- |
-LL | foo(|_|)
- | ^ expected expression
-
-error: aborting due to previous error
-
+++ /dev/null
-// Issue #33262
-
-pub fn main() {
- for i in 0..a as { }
- //~^ ERROR expected type, found `{`
-}
+++ /dev/null
-error: expected type, found `{`
- --> $DIR/issue-33262.rs:4:22
- |
-LL | for i in 0..a as { }
- | ^ expected type
-
-error: aborting due to previous error
-
+++ /dev/null
-struct S;
-
-impl S {
- fn f(*, a: u8) -> u8 {}
- //~^ ERROR expected parameter name, found `*`
- //~| ERROR mismatched types
-}
-
-fn main() {}
+++ /dev/null
-error: expected parameter name, found `*`
- --> $DIR/issue-33413.rs:4:10
- |
-LL | fn f(*, a: u8) -> u8 {}
- | ^ expected parameter name
-
-error[E0308]: mismatched types
- --> $DIR/issue-33413.rs:4:23
- |
-LL | fn f(*, a: u8) -> u8 {}
- | - ^^ expected `u8`, found `()`
- | |
- | implicitly returns `()` as its body has no tail or `return` expression
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// run-rustfix
-
-trait Tr {}
-//~^ ERROR negative bounds are not supported
-trait Tr2: SuperA {}
-//~^ ERROR negative bounds are not supported
-trait Tr3: SuperB {}
-//~^ ERROR negative bounds are not supported
-trait Tr4: SuperB + SuperD {}
-//~^ ERROR negative bounds are not supported
-trait Tr5 {}
-//~^ ERROR negative bounds are not supported
-
-trait SuperA {}
-trait SuperB {}
-trait SuperC {}
-trait SuperD {}
-
-fn main() {}
+++ /dev/null
-// run-rustfix
-
-trait Tr: !SuperA {}
-//~^ ERROR negative bounds are not supported
-trait Tr2: SuperA + !SuperB {}
-//~^ ERROR negative bounds are not supported
-trait Tr3: !SuperA + SuperB {}
-//~^ ERROR negative bounds are not supported
-trait Tr4: !SuperA + SuperB
- + !SuperC + SuperD {}
-//~^ ERROR negative bounds are not supported
-trait Tr5: !SuperA
- + !SuperB {}
-//~^ ERROR negative bounds are not supported
-
-trait SuperA {}
-trait SuperB {}
-trait SuperC {}
-trait SuperD {}
-
-fn main() {}
+++ /dev/null
-error: negative bounds are not supported
- --> $DIR/issue-33418.rs:3:9
- |
-LL | trait Tr: !SuperA {}
- | ^^^^^^^^^ negative bounds are not supported
-
-error: negative bounds are not supported
- --> $DIR/issue-33418.rs:5:19
- |
-LL | trait Tr2: SuperA + !SuperB {}
- | ^^^^^^^^^ negative bounds are not supported
-
-error: negative bounds are not supported
- --> $DIR/issue-33418.rs:7:10
- |
-LL | trait Tr3: !SuperA + SuperB {}
- | ^^^^^^^^^ negative bounds are not supported
-
-error: negative bounds are not supported
- --> $DIR/issue-33418.rs:9:10
- |
-LL | trait Tr4: !SuperA + SuperB
- | ^^^^^^^^^
-LL | + !SuperC + SuperD {}
- | ^^^^^^^^^ negative bounds are not supported
-
-error: negative bounds are not supported
- --> $DIR/issue-33418.rs:12:10
- |
-LL | trait Tr5: !SuperA
- | ^^^^^^^^^
-LL | + !SuperB {}
- | ^^^^^^^^^ negative bounds are not supported
-
-error: aborting due to 5 previous errors
-
+++ /dev/null
-use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.`
+++ /dev/null
-error: expected one of `::`, `;`, or `as`, found `.`
- --> $DIR/issue-33455.rs:1:8
- |
-LL | use foo.bar;
- | ^ expected one of `::`, `;`, or `as`
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {
- /// comment //~ ERROR found a documentation comment that doesn't document anything
-}
+++ /dev/null
-error[E0585]: found a documentation comment that doesn't document anything
- --> $DIR/issue-34222-1.rs:2:5
- |
-LL | /// comment
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = help: doc comments must come before what they document, maybe a comment was intended with `//`?
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0585`.
+++ /dev/null
-enum Test {
- Drill {
- field: i32,
- }
-}
-
-fn main() {
- Test::Drill(field: 42);
- //~^ ERROR invalid `struct` delimiters or `fn` call arguments
-}
+++ /dev/null
-error: invalid `struct` delimiters or `fn` call arguments
- --> $DIR/issue-34255-1.rs:8:5
- |
-LL | Test::Drill(field: 42);
- | ^^^^^^^^^^^^^^^^^^^^^^
- |
-help: if `Test::Drill` is a struct, use braces as delimiters
- |
-LL | Test::Drill { field: 42 };
- | ~ ~
-help: if `Test::Drill` is a function, use the arguments directly
- |
-LL - Test::Drill(field: 42);
-LL + Test::Drill(42);
- |
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-#![crate_type = "lib"]
-#![feature(type_ascription)]
-use std::future::Future;
-use std::pin::Pin;
-
-// This tests the parser for "x as Y[z]". It errors, but we want to give useful
-// errors and parse such that further code gives useful errors.
-pub fn index_after_as_cast() {
- vec![1, 2, 3] as Vec<i32>[0];
- //~^ ERROR: casts cannot be followed by indexing
- vec![1, 2, 3]: Vec<i32>[0];
- //~^ ERROR: casts cannot be followed by indexing
-}
-
-pub fn index_after_cast_to_index() {
- (&[0]) as &[i32][0];
- //~^ ERROR: casts cannot be followed by indexing
- (&[0i32]): &[i32; 1][0];
- //~^ ERROR: casts cannot be followed by indexing
-}
-
-pub fn cast_after_cast() {
- if 5u64 as i32 as u16 == 0u16 {
-
- }
- if 5u64: u64: u64 == 0u64 {
-
- }
- let _ = 5u64: u64: u64 as u8 as i8 == 9i8;
- let _ = 0i32: i32: i32;
- let _ = 0 as i32: i32;
- let _ = 0i32: i32 as i32;
- let _ = 0 as i32 as i32;
- let _ = 0i32: i32: i32 as u32 as i32;
-}
-
-pub fn cast_cast_method_call() {
- let _ = 0i32: i32: i32.count_ones();
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0 as i32: i32.count_ones();
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0i32: i32 as i32.count_ones();
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0 as i32 as i32.count_ones();
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0i32: i32: i32 as u32 as i32.count_ones();
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0i32: i32.count_ones(): u32;
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0 as i32.count_ones(): u32;
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0i32: i32.count_ones() as u32;
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0 as i32.count_ones() as u32;
- //~^ ERROR: casts cannot be followed by a method call
- let _ = 0i32: i32: i32.count_ones() as u32 as i32;
- //~^ ERROR: casts cannot be followed by a method call
-}
-
-pub fn multiline_error() {
- let _ = 0
- as i32
- .count_ones();
- //~^^^ ERROR: casts cannot be followed by a method call
-}
-
-// this tests that the precedence for `!x as Y.Z` is still what we expect
-pub fn precedence() {
- let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
- //~^ ERROR: casts cannot be followed by indexing
-}
-
-pub fn method_calls() {
- 0 as i32.max(0);
- //~^ ERROR: casts cannot be followed by a method call
- 0: i32.max(0);
- //~^ ERROR: casts cannot be followed by a method call
-}
-
-pub fn complex() {
- let _ = format!(
- "{} and {}",
- if true { 33 } else { 44 } as i32.max(0),
- //~^ ERROR: casts cannot be followed by a method call
- if true { 33 } else { 44 }: i32.max(0)
- //~^ ERROR: casts cannot be followed by a method call
- );
-}
-
-pub fn in_condition() {
- if 5u64 as i32.max(0) == 0 {
- //~^ ERROR: casts cannot be followed by a method call
- }
- if 5u64: u64.max(0) == 0 {
- //~^ ERROR: casts cannot be followed by a method call
- }
-}
-
-pub fn inside_block() {
- let _ = if true {
- 5u64 as u32.max(0) == 0
- //~^ ERROR: casts cannot be followed by a method call
- } else { false };
- let _ = if true {
- 5u64: u64.max(0) == 0
- //~^ ERROR: casts cannot be followed by a method call
- } else { false };
-}
-
-static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
-//~^ ERROR: casts cannot be followed by indexing
-
-static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
-//~^ ERROR: casts cannot be followed by indexing
-
-
-pub fn cast_then_try() -> Result<u64,u64> {
- Err(0u64) as Result<u64,u64>?;
- //~^ ERROR: casts cannot be followed by ?
- Err(0u64): Result<u64,u64>?;
- //~^ ERROR: casts cannot be followed by ?
- Ok(1)
-}
-
-
-pub fn cast_then_call() {
- type F = fn(u8);
- // type ascription won't actually do [unique drop fn type] -> fn(u8) casts.
- let drop_ptr = drop as fn(u8);
- drop as F();
- //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214]
- drop_ptr: F();
- //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214]
-}
-
-pub fn cast_to_fn_should_work() {
- let drop_ptr = drop as fn(u8);
- drop as fn(u8);
- drop_ptr: fn(u8);
-}
-
-pub fn parens_after_cast_error() {
- let drop_ptr = drop as fn(u8);
- drop as fn(u8)(0);
- //~^ ERROR: casts cannot be followed by a function call
- drop_ptr: fn(u8)(0);
- //~^ ERROR: casts cannot be followed by a function call
-}
-
-pub async fn cast_then_await() {
- Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
- //~^ ERROR: casts cannot be followed by `.await`
-
- Box::pin(noop()): Pin<Box<_>>.await;
- //~^ ERROR: casts cannot be followed by `.await`
-}
-
-pub async fn noop() {}
-
-#[derive(Default)]
-pub struct Foo {
- pub bar: u32,
-}
-
-pub fn struct_field() {
- Foo::default() as Foo.bar;
- //~^ ERROR: cannot be followed by a field access
- Foo::default(): Foo.bar;
- //~^ ERROR: cannot be followed by a field access
-}
+++ /dev/null
-error: casts cannot be followed by indexing
- --> $DIR/issue-35813-postfix-after-cast.rs:10:5
- |
-LL | vec![1, 2, 3] as Vec<i32>[0];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (vec![1, 2, 3] as Vec<i32>)[0];
- | + +
-
-error: casts cannot be followed by indexing
- --> $DIR/issue-35813-postfix-after-cast.rs:12:5
- |
-LL | vec![1, 2, 3]: Vec<i32>[0];
- | ^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (vec![1, 2, 3]: Vec<i32>)[0];
- | + +
-
-error: casts cannot be followed by indexing
- --> $DIR/issue-35813-postfix-after-cast.rs:17:5
- |
-LL | (&[0]) as &[i32][0];
- | ^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | ((&[0]) as &[i32])[0];
- | + +
-
-error: casts cannot be followed by indexing
- --> $DIR/issue-35813-postfix-after-cast.rs:19:5
- |
-LL | (&[0i32]): &[i32; 1][0];
- | ^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | ((&[0i32]): &[i32; 1])[0];
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:39:13
- |
-LL | let _ = 0i32: i32: i32.count_ones();
- | ^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0i32: i32: i32).count_ones();
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:41:13
- |
-LL | let _ = 0 as i32: i32.count_ones();
- | ^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0 as i32: i32).count_ones();
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:43:13
- |
-LL | let _ = 0i32: i32 as i32.count_ones();
- | ^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0i32: i32 as i32).count_ones();
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:45:13
- |
-LL | let _ = 0 as i32 as i32.count_ones();
- | ^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0 as i32 as i32).count_ones();
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:47:13
- |
-LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0i32: i32: i32 as u32 as i32).count_ones();
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:49:13
- |
-LL | let _ = 0i32: i32.count_ones(): u32;
- | ^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0i32: i32).count_ones(): u32;
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:51:13
- |
-LL | let _ = 0 as i32.count_ones(): u32;
- | ^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0 as i32).count_ones(): u32;
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:53:13
- |
-LL | let _ = 0i32: i32.count_ones() as u32;
- | ^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0i32: i32).count_ones() as u32;
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:55:13
- |
-LL | let _ = 0 as i32.count_ones() as u32;
- | ^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0 as i32).count_ones() as u32;
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:57:13
- |
-LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32;
- | ^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let _ = (0i32: i32: i32).count_ones() as u32 as i32;
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:62:13
- |
-LL | let _ = 0
- | _____________^
-LL | | as i32
- | |______________^
- |
-help: try surrounding the expression in parentheses
- |
-LL ~ let _ = (0
-LL ~ as i32)
- |
-
-error: casts cannot be followed by indexing
- --> $DIR/issue-35813-postfix-after-cast.rs:70:18
- |
-LL | let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | let x: i32 = (&vec![1, 2, 3] as &Vec<i32>)[0];
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:75:5
- |
-LL | 0 as i32.max(0);
- | ^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (0 as i32).max(0);
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:77:5
- |
-LL | 0: i32.max(0);
- | ^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (0: i32).max(0);
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:92:8
- |
-LL | if 5u64 as i32.max(0) == 0 {
- | ^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | if (5u64 as i32).max(0) == 0 {
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:95:8
- |
-LL | if 5u64: u64.max(0) == 0 {
- | ^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | if (5u64: u64).max(0) == 0 {
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:102:9
- |
-LL | 5u64 as u32.max(0) == 0
- | ^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (5u64 as u32).max(0) == 0
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:106:9
- |
-LL | 5u64: u64.max(0) == 0
- | ^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (5u64: u64).max(0) == 0
- | + +
-
-error: casts cannot be followed by indexing
- --> $DIR/issue-35813-postfix-after-cast.rs:111:24
- |
-LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
- | ^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]);
- | + +
-
-error: casts cannot be followed by indexing
- --> $DIR/issue-35813-postfix-after-cast.rs:114:25
- |
-LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
- | ^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | static bar2: &[i32] = &((&[1i32,2,3]: &[i32; 3])[0..1]);
- | + +
-
-error: casts cannot be followed by ?
- --> $DIR/issue-35813-postfix-after-cast.rs:119:5
- |
-LL | Err(0u64) as Result<u64,u64>?;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (Err(0u64) as Result<u64,u64>)?;
- | + +
-
-error: casts cannot be followed by ?
- --> $DIR/issue-35813-postfix-after-cast.rs:121:5
- |
-LL | Err(0u64): Result<u64,u64>?;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (Err(0u64): Result<u64,u64>)?;
- | + +
-
-error: casts cannot be followed by a function call
- --> $DIR/issue-35813-postfix-after-cast.rs:145:5
- |
-LL | drop as fn(u8)(0);
- | ^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (drop as fn(u8))(0);
- | + +
-
-error: casts cannot be followed by a function call
- --> $DIR/issue-35813-postfix-after-cast.rs:147:5
- |
-LL | drop_ptr: fn(u8)(0);
- | ^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (drop_ptr: fn(u8))(0);
- | + +
-
-error: casts cannot be followed by `.await`
- --> $DIR/issue-35813-postfix-after-cast.rs:152:5
- |
-LL | Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await;
- | + +
-
-error: casts cannot be followed by `.await`
- --> $DIR/issue-35813-postfix-after-cast.rs:155:5
- |
-LL | Box::pin(noop()): Pin<Box<_>>.await;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (Box::pin(noop()): Pin<Box<_>>).await;
- | + +
-
-error: casts cannot be followed by a field access
- --> $DIR/issue-35813-postfix-after-cast.rs:167:5
- |
-LL | Foo::default() as Foo.bar;
- | ^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (Foo::default() as Foo).bar;
- | + +
-
-error: casts cannot be followed by a field access
- --> $DIR/issue-35813-postfix-after-cast.rs:169:5
- |
-LL | Foo::default(): Foo.bar;
- | ^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (Foo::default(): Foo).bar;
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:84:9
- |
-LL | if true { 33 } else { 44 } as i32.max(0),
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (if true { 33 } else { 44 } as i32).max(0),
- | + +
-
-error: casts cannot be followed by a method call
- --> $DIR/issue-35813-postfix-after-cast.rs:86:9
- |
-LL | if true { 33 } else { 44 }: i32.max(0)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-help: try surrounding the expression in parentheses
- |
-LL | (if true { 33 } else { 44 }: i32).max(0)
- | + +
-
-error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
- --> $DIR/issue-35813-postfix-after-cast.rs:131:13
- |
-LL | drop as F();
- | ^^^ only `Fn` traits may use parentheses
-
-error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
- --> $DIR/issue-35813-postfix-after-cast.rs:133:15
- |
-LL | drop_ptr: F();
- | ^^^ only `Fn` traits may use parentheses
-
-error: aborting due to 36 previous errors
-
-For more information about this error, try `rustc --explain E0214`.
+++ /dev/null
-struct S;
-
-impl S {
- pub //~ ERROR visibility `pub` is not followed by an item
-} //~ ERROR non-item in item list
-
-fn main() {}
+++ /dev/null
-error: visibility `pub` is not followed by an item
- --> $DIR/issue-41155.rs:4:5
- |
-LL | pub
- | ^^^ the visibility
- |
- = help: you likely meant to define an item, e.g., `pub fn foo() {}`
-
-error: non-item in item list
- --> $DIR/issue-41155.rs:5:1
- |
-LL | impl S {
- | - item list starts here
-LL | pub
-LL | }
- | ^
- | |
- | non-item starts here
- | item list ends here
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-fn main() {
- |
-}
-//~^ ERROR expected `|`, found `}`
-|
-//~^ ERROR expected item, found `|`
+++ /dev/null
-error: expected `|`, found `}`
- --> $DIR/issue-43196.rs:3:1
- |
-LL | |
- | - expected `|`
-LL | }
- | ^ unexpected token
-
-error: expected item, found `|`
- --> $DIR/issue-43196.rs:5:1
- |
-LL | |
- | ^ expected item
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-fn main() {
- '\u{_10FFFF}'; //~ ERROR invalid start of unicode escape
-}
+++ /dev/null
-error: invalid start of unicode escape: `_`
- --> $DIR/issue-43692.rs:2:9
- |
-LL | '\u{_10FFFF}';
- | ^ invalid start of unicode escape
-
-error: aborting due to previous error
-
+++ /dev/null
-struct MyStruct;
-impl MyStruct {
- fn f() {|x, y} //~ ERROR expected one of `:`, `@`, or `|`, found `}`
-}
-
-fn main() {}
+++ /dev/null
-error: expected one of `:`, `@`, or `|`, found `}`
- --> $DIR/issue-44021.rs:3:18
- |
-LL | fn f() {|x, y}
- | ^ expected one of `:`, `@`, or `|`
-
-error: aborting due to previous error
-
+++ /dev/null
-macro_rules! foo {
- ($rest: tt) => {
- bar(baz: $rest) //~ ERROR invalid `struct` delimiters or `fn` call arguments
- }
-}
-
-fn main() {
- foo!(true);
- //~^ ERROR expected identifier, found keyword
-}
+++ /dev/null
-error: expected identifier, found keyword `true`
- --> $DIR/issue-44406.rs:8:10
- |
-LL | foo!(true);
- | ^^^^ expected identifier, found keyword
- |
-help: you can escape reserved keywords to use them as identifiers
- |
-LL | foo!(r#true);
- | ~~~~~~
-
-error: invalid `struct` delimiters or `fn` call arguments
- --> $DIR/issue-44406.rs:3:9
- |
-LL | bar(baz: $rest)
- | ^^^^^^^^^^^^^^^
-...
-LL | foo!(true);
- | ---------- in this macro invocation
- |
- = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: if `bar` is a struct, use braces as delimiters
- |
-LL | bar { }
- | ~
-help: if `bar` is a function, use the arguments directly
- |
-LL - bar(baz: $rest)
-LL + bar(: $rest)
- |
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-fn main() {
- let unused = ();
-
- #![allow(unused_variables)] //~ ERROR not permitted in this context
- fn foo() {}
-}
+++ /dev/null
-error: an inner attribute is not permitted in this context
- --> $DIR/issue-45296.rs:4:5
- |
-LL | #![allow(unused_variables)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL | fn foo() {}
- | ----------- the inner attribute doesn't annotate this function
- |
- = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
-help: to annotate the function, change the attribute from inner to outer style
- |
-LL - #![allow(unused_variables)]
-LL + #[allow(unused_variables)]
- |
-
-error: aborting due to previous error
-
+++ /dev/null
-// run-rustfix
-
-pub struct Struct {
- pub a: usize,
-}
-//~^ ERROR expected item, found `;`
-
-fn main() {}
+++ /dev/null
-// run-rustfix
-
-pub struct Struct {
- pub a: usize,
-};
-//~^ ERROR expected item, found `;`
-
-fn main() {}
+++ /dev/null
-error: expected item, found `;`
- --> $DIR/issue-46186.rs:5:2
- |
-LL | };
- | ^ help: remove this semicolon
- |
- = help: braced struct declarations are not followed by a semicolon
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {}
-
-macro_rules! expand_to_enum {
- () => {
- enum BadE {}
- //~^ ERROR enum is not supported in `trait`s or `impl`s
- //~| ERROR enum is not supported in `trait`s or `impl`s
- //~| ERROR enum is not supported in `extern` blocks
- };
-}
-
-macro_rules! mac_impl {
- ($($i:item)*) => {
- struct S;
- impl S { $($i)* }
- }
-}
-
-mac_impl! {
- struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s
- expand_to_enum!();
-}
-
-macro_rules! mac_trait {
- ($($i:item)*) => {
- trait T { $($i)* }
- }
-}
-
-mac_trait! {
- struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s
- expand_to_enum!();
-}
-
-macro_rules! mac_extern {
- ($($i:item)*) => {
- extern "C" { $($i)* }
- }
-}
-
-mac_extern! {
- struct BadS; //~ ERROR struct is not supported in `extern` blocks
- expand_to_enum!();
-}
+++ /dev/null
-error: struct is not supported in `trait`s or `impl`s
- --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:20:5
- |
-LL | struct BadS;
- | ^^^^^^^^^^^^
- |
- = help: consider moving the struct out to a nearby module scope
-
-error: enum is not supported in `trait`s or `impl`s
- --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
- |
-LL | enum BadE {}
- | ^^^^^^^^^
-...
-LL | expand_to_enum!();
- | ----------------- in this macro invocation
- |
- = help: consider moving the enum out to a nearby module scope
- = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: struct is not supported in `trait`s or `impl`s
- --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:31:5
- |
-LL | struct BadS;
- | ^^^^^^^^^^^^
- |
- = help: consider moving the struct out to a nearby module scope
-
-error: enum is not supported in `trait`s or `impl`s
- --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
- |
-LL | enum BadE {}
- | ^^^^^^^^^
-...
-LL | expand_to_enum!();
- | ----------------- in this macro invocation
- |
- = help: consider moving the enum out to a nearby module scope
- = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: struct is not supported in `extern` blocks
- --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:42:5
- |
-LL | struct BadS;
- | ^^^^^^^^^^^^
- |
- = help: consider moving the struct out to a nearby module scope
-
-error: enum is not supported in `extern` blocks
- --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
- |
-LL | enum BadE {}
- | ^^^^^^^^^
-...
-LL | expand_to_enum!();
- | ----------------- in this macro invocation
- |
- = help: consider moving the enum out to a nearby module scope
- = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to 6 previous errors
-
+++ /dev/null
-// check-pass
-
-fn main() {}
-
-macro_rules! mac_impl {
- ($i:item) => {
- struct S;
- impl S { $i }
- }
-}
-
-mac_impl! {
- fn foo() {}
-}
-
-macro_rules! mac_trait {
- ($i:item) => {
- trait T { $i }
- }
-}
-
-mac_trait! {
- fn foo() {}
-}
-
-macro_rules! mac_extern {
- ($i:item) => {
- extern "C" { $i }
- }
-}
-
-mac_extern! {
- fn foo();
-}
+++ /dev/null
-// run-pass
-// ignore-test Not a test. Used by issue-48508.rs
-
-pub fn other() -> f64 {
- let µ = 1.0;
- µ
-}
+++ /dev/null
-// run-pass
-// Regression test for issue #48508:
-//
-// Confusion between global and local file offsets caused incorrect handling of multibyte character
-// spans when compiling multiple files. One visible effect was an ICE generating debug information
-// when a multibyte character is at the end of a scope. The problematic code is actually in
-// issue-48508-aux.rs
-
-// compile-flags:-g
-// ignore-pretty issue #37195
-// ignore-asmjs wasm2js does not support source maps yet
-
-#![allow(uncommon_codepoints)]
-
-#[path = "issue-48508-aux.rs"]
-mod other_file;
-
-fn main() {
- other_file::other();
-}
+++ /dev/null
-// run-rustfix
-
-#![allow(dead_code)]
-
-struct S {
- x: u8,
- /// The ID of the parent core
- y: u8,
-}
-//~^^^ ERROR found a documentation comment that doesn't document anything
-
-fn main() {}
+++ /dev/null
-// run-rustfix
-
-#![allow(dead_code)]
-
-struct S {
- x: u8
- /// The ID of the parent core
- y: u8,
-}
-//~^^^ ERROR found a documentation comment that doesn't document anything
-
-fn main() {}
+++ /dev/null
-error[E0585]: found a documentation comment that doesn't document anything
- --> $DIR/issue-48636.rs:7:5
- |
-LL | x: u8
- | - help: missing comma here: `,`
-LL | /// The ID of the parent core
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = help: doc comments must come before what they document, maybe a comment was intended with `//`?
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0585`.
+++ /dev/null
-#![allow(unused_variables)]; //~ ERROR expected item, found `;`
-//~^ ERROR `main` function
-fn foo() {}
+++ /dev/null
-error: expected item, found `;`
- --> $DIR/issue-49040.rs:1:28
- |
-LL | #![allow(unused_variables)];
- | ^ help: remove this semicolon
-
-error[E0601]: `main` function not found in crate `issue_49040`
- --> $DIR/issue-49040.rs:1:1
- |
-LL | #![allow(unused_variables)];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `$DIR/issue-49040.rs`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0601`.
+++ /dev/null
-fn main(){
- if i in 1..10 {
-//~^ ERROR expected `{`, found keyword `in`
- break;
- }
-}
+++ /dev/null
-error: expected `{`, found keyword `in`
- --> $DIR/issue-51602.rs:2:10
- |
-LL | if i in 1..10 {
- | -- ^^ expected `{`
- | |
- | this `if` expression has a condition, but no block
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Foo { bar: f64, baz: i64, bat: i64 }
-
-fn main() {
- let _ = Foo { bar: .5, baz: 42 };
- //~^ ERROR float literals must have an integer part
- //~| ERROR missing field `bat` in initializer of `Foo`
- let bar = 1.5f32;
- let _ = Foo { bar.into(), bat: -1, . };
- //~^ ERROR expected one of
- //~| ERROR missing fields `bar` and `baz` in initializer of `Foo`
- //~| ERROR expected identifier, found `.`
-}
+++ /dev/null
-error: float literals must have an integer part
- --> $DIR/issue-52496.rs:4:24
- |
-LL | let _ = Foo { bar: .5, baz: 42 };
- | ^^ help: must have an integer part: `0.5`
-
-error: expected one of `,` or `}`, found `.`
- --> $DIR/issue-52496.rs:8:22
- |
-LL | let _ = Foo { bar.into(), bat: -1, . };
- | --- ^ expected one of `,` or `}`
- | |
- | while parsing this struct
-
-error: expected identifier, found `.`
- --> $DIR/issue-52496.rs:8:40
- |
-LL | let _ = Foo { bar.into(), bat: -1, . };
- | --- ^ expected identifier
- | |
- | while parsing this struct
-
-error[E0063]: missing field `bat` in initializer of `Foo`
- --> $DIR/issue-52496.rs:4:13
- |
-LL | let _ = Foo { bar: .5, baz: 42 };
- | ^^^ missing `bat`
-
-error[E0063]: missing fields `bar` and `baz` in initializer of `Foo`
- --> $DIR/issue-52496.rs:8:13
- |
-LL | let _ = Foo { bar.into(), bat: -1, . };
- | ^^^ missing `bar` and `baz`
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0063`.
+++ /dev/null
-// check-pass
-
-// This test checks that the `remove extra angle brackets` error doesn't happen for some
-// potential edge-cases..
-
-struct X {
- len: u32,
-}
-
-fn main() {
- let x = X { len: 3 };
-
- let _ = x.len > (3);
-
- let _ = x.len >> (3);
-}
+++ /dev/null
-// run-rustfix
-
-// This test checks that the following error is emitted and the suggestion works:
-//
-// ```
-// let _ = Vec::<usize>>>::new();
-// ^^ help: remove extra angle brackets
-// ```
-
-fn main() {
- let _ = Vec::<usize>::new();
- //~^ ERROR unmatched angle bracket
-
- let _ = Vec::<usize>::new();
- //~^ ERROR unmatched angle bracket
-
- let _ = Vec::<usize>::new();
- //~^ ERROR unmatched angle bracket
-
- let _ = Vec::<usize>::new();
- //~^ ERROR unmatched angle bracket
-}
+++ /dev/null
-// run-rustfix
-
-// This test checks that the following error is emitted and the suggestion works:
-//
-// ```
-// let _ = Vec::<usize>>>::new();
-// ^^ help: remove extra angle brackets
-// ```
-
-fn main() {
- let _ = Vec::<usize>>>>>::new();
- //~^ ERROR unmatched angle bracket
-
- let _ = Vec::<usize>>>>::new();
- //~^ ERROR unmatched angle bracket
-
- let _ = Vec::<usize>>>::new();
- //~^ ERROR unmatched angle bracket
-
- let _ = Vec::<usize>>::new();
- //~^ ERROR unmatched angle bracket
-}
+++ /dev/null
-error: unmatched angle brackets
- --> $DIR/issue-54521-2.rs:11:25
- |
-LL | let _ = Vec::<usize>>>>>::new();
- | ^^^^ help: remove extra angle brackets
-
-error: unmatched angle brackets
- --> $DIR/issue-54521-2.rs:14:25
- |
-LL | let _ = Vec::<usize>>>>::new();
- | ^^^ help: remove extra angle brackets
-
-error: unmatched angle brackets
- --> $DIR/issue-54521-2.rs:17:25
- |
-LL | let _ = Vec::<usize>>>::new();
- | ^^ help: remove extra angle brackets
-
-error: unmatched angle bracket
- --> $DIR/issue-54521-2.rs:20:25
- |
-LL | let _ = Vec::<usize>>::new();
- | ^ help: remove extra angle bracket
-
-error: aborting due to 4 previous errors
-
+++ /dev/null
-// run-rustfix
-
-// This test checks that the following error is emitted and the suggestion works:
-//
-// ```
-// let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
-// ^^ help: remove extra angle brackets
-// ```
-
-fn main() {
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-}
+++ /dev/null
-// run-rustfix
-
-// This test checks that the following error is emitted and the suggestion works:
-//
-// ```
-// let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
-// ^^ help: remove extra angle brackets
-// ```
-
-fn main() {
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>();
- //~^ ERROR unmatched angle bracket
-}
+++ /dev/null
-error: unmatched angle brackets
- --> $DIR/issue-54521-3.rs:11:60
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>>();
- | ^^^^ help: remove extra angle brackets
-
-error: unmatched angle brackets
- --> $DIR/issue-54521-3.rs:14:60
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>();
- | ^^^ help: remove extra angle brackets
-
-error: unmatched angle brackets
- --> $DIR/issue-54521-3.rs:17:60
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
- | ^^ help: remove extra angle brackets
-
-error: unmatched angle bracket
- --> $DIR/issue-54521-3.rs:20:60
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>();
- | ^ help: remove extra angle bracket
-
-error: aborting due to 4 previous errors
-
+++ /dev/null
-fn main() {
- let __isize = 340282366920938463463374607431768211456; // 2^128
- //~^ ERROR integer literal is too large
-}
+++ /dev/null
-error: integer literal is too large
- --> $DIR/issue-5544-a.rs:2:19
- |
-LL | let __isize = 340282366920938463463374607431768211456; // 2^128
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {
- let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff;
- //~^ ERROR integer literal is too large
-}
+++ /dev/null
-error: integer literal is too large
- --> $DIR/issue-5544-b.rs:2:19
- |
-LL | let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-struct T;
-
-impl for T {}
-//~^ ERROR missing trait in a trait impl
-
-fn main() {}
+++ /dev/null
-error: missing trait in a trait impl
- --> $DIR/issue-56031.rs:3:5
- |
-LL | impl for T {}
- | ^
- |
-help: add a trait here
- |
-LL | impl Trait for T {}
- | +++++
-help: for an inherent impl, drop this `for`
- |
-LL - impl for T {}
-LL + impl T {}
- |
-
-error: aborting due to previous error
-
+++ /dev/null
-mod m {
- pub fn r#for() {}
-}
-
-fn main() {
- m::for();
- //~^ ERROR expected identifier, found keyword `for`
-}
+++ /dev/null
-error: expected identifier, found keyword `for`
- --> $DIR/issue-57198.rs:6:8
- |
-LL | m::for();
- | ^^^ expected identifier, found keyword
- |
-help: you can escape reserved keywords to use them as identifiers
- |
-LL | m::r#for();
- | ~~~~~
-
-error: aborting due to previous error
-
+++ /dev/null
-// run-rustfix
-
-#![allow(warnings)]
-
-// This test checks that the following error is emitted when a `=` character is used to initialize
-// a struct field when a `:` is expected.
-//
-// ```
-// error: struct fields are initialized with a colon
-// --> $DIR/issue-57684.rs:12:20
-// |
-// LL | let _ = X { f1 = 5 };
-// | ^ help: replace equals symbol with a colon: `:`
-// ```
-
-struct X {
- f1: i32,
-}
-
-struct Y {
- f1: i32,
- f2: i32,
- f3: i32,
-}
-
-fn main() {
- let _ = X { f1: 5 };
- //~^ ERROR expected `:`, found `=`
-
- let f3 = 3;
- let _ = Y {
- f1: 5,
- //~^ ERROR expected `:`, found `=`
- f2: 4,
- f3,
- };
-}
+++ /dev/null
-// run-rustfix
-
-#![allow(warnings)]
-
-// This test checks that the following error is emitted when a `=` character is used to initialize
-// a struct field when a `:` is expected.
-//
-// ```
-// error: struct fields are initialized with a colon
-// --> $DIR/issue-57684.rs:12:20
-// |
-// LL | let _ = X { f1 = 5 };
-// | ^ help: replace equals symbol with a colon: `:`
-// ```
-
-struct X {
- f1: i32,
-}
-
-struct Y {
- f1: i32,
- f2: i32,
- f3: i32,
-}
-
-fn main() {
- let _ = X { f1 = 5 };
- //~^ ERROR expected `:`, found `=`
-
- let f3 = 3;
- let _ = Y {
- f1 = 5,
- //~^ ERROR expected `:`, found `=`
- f2: 4,
- f3,
- };
-}
+++ /dev/null
-error: expected `:`, found `=`
- --> $DIR/issue-57684.rs:27:20
- |
-LL | let _ = X { f1 = 5 };
- | -^
- | |
- | help: replace equals symbol with a colon: `:`
-
-error: expected `:`, found `=`
- --> $DIR/issue-57684.rs:32:12
- |
-LL | f1 = 5,
- | -^
- | |
- | help: replace equals symbol with a colon: `:`
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-// run-rustfix
-
-#![allow(warnings)]
-
-// This test checks that the following error is emitted and the suggestion works:
-//
-// ```
-// let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
-// ^^ help: remove extra angle brackets
-// ```
-
-trait Foo {
- type Output;
-}
-
-fn foo<T: Foo>() {
- // More complex cases with more than one correct leading `<` character:
-
- bar::<<T as Foo>::Output>();
- //~^ ERROR unmatched angle bracket
-
- bar::<<T as Foo>::Output>();
- //~^ ERROR unmatched angle bracket
-
- bar::<<T as Foo>::Output>();
- //~^ ERROR unmatched angle bracket
-
- bar::<<T as Foo>::Output>();
-}
-
-fn bar<T>() {}
-
-fn main() {
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
-}
+++ /dev/null
-// run-rustfix
-
-#![allow(warnings)]
-
-// This test checks that the following error is emitted and the suggestion works:
-//
-// ```
-// let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
-// ^^ help: remove extra angle brackets
-// ```
-
-trait Foo {
- type Output;
-}
-
-fn foo<T: Foo>() {
- // More complex cases with more than one correct leading `<` character:
-
- bar::<<<<<T as Foo>::Output>();
- //~^ ERROR unmatched angle bracket
-
- bar::<<<<T as Foo>::Output>();
- //~^ ERROR unmatched angle bracket
-
- bar::<<<T as Foo>::Output>();
- //~^ ERROR unmatched angle bracket
-
- bar::<<T as Foo>::Output>();
-}
-
-fn bar<T>() {}
-
-fn main() {
- let _ = vec![1, 2, 3].into_iter().collect::<<<<<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<<<<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<<Vec<usize>>();
- //~^ ERROR unmatched angle bracket
-
- let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
-}
+++ /dev/null
-error: unmatched angle brackets
- --> $DIR/issue-57819.rs:19:10
- |
-LL | bar::<<<<<T as Foo>::Output>();
- | ^^^ help: remove extra angle brackets
-
-error: unmatched angle brackets
- --> $DIR/issue-57819.rs:22:10
- |
-LL | bar::<<<<T as Foo>::Output>();
- | ^^ help: remove extra angle brackets
-
-error: unmatched angle bracket
- --> $DIR/issue-57819.rs:25:10
- |
-LL | bar::<<<T as Foo>::Output>();
- | ^ help: remove extra angle bracket
-
-error: unmatched angle brackets
- --> $DIR/issue-57819.rs:34:48
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<<<<<Vec<usize>>();
- | ^^^^ help: remove extra angle brackets
-
-error: unmatched angle brackets
- --> $DIR/issue-57819.rs:37:48
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<<<<Vec<usize>>();
- | ^^^ help: remove extra angle brackets
-
-error: unmatched angle brackets
- --> $DIR/issue-57819.rs:40:48
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
- | ^^ help: remove extra angle brackets
-
-error: unmatched angle bracket
- --> $DIR/issue-57819.rs:43:48
- |
-LL | let _ = vec![1, 2, 3].into_iter().collect::<<Vec<usize>>();
- | ^ help: remove extra angle bracket
-
-error: aborting due to 7 previous errors
-
+++ /dev/null
-// normalize-stderr-test: "parser:.*\(" -> "parser: $$ACCESS_DENIED_MSG ("
-// normalize-stderr-test: "os error \d+" -> "os error $$ACCESS_DENIED_CODE"
-
-#[path = "../parser"]
-mod foo; //~ ERROR couldn't read
-
-fn main() {}
+++ /dev/null
-error: couldn't read $DIR/../parser: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE)
- --> $DIR/issue-5806.rs:5:1
- |
-LL | mod foo;
- | ^^^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-// Fixed in #66054.
-// ignore-tidy-trailing-newlines
-// error-pattern: aborting due to 2 previous errors
-#[Ѕ
\ No newline at end of file
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-58094-missing-right-square-bracket.rs:4:4
- |
-LL | #[Ѕ
- | - ^
- | |
- | unclosed delimiter
-
-error: expected item after attributes
- --> $DIR/issue-58094-missing-right-square-bracket.rs:4:1
- |
-LL | #[Ѕ
- | ^^^
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-impl A {
- //~^ ERROR cannot find type `A` in this scope
- fn b(self>
- //~^ ERROR expected one of `)`, `,`, or `:`, found `>`
- //~| ERROR expected one of `->`, `;`, `where`, or `{`, found `>`
-}
-
-fn main() {}
+++ /dev/null
-error: expected one of `)`, `,`, or `:`, found `>`
- --> $DIR/issue-58856-1.rs:3:9
- |
-LL | fn b(self>
- | ^ ^ help: `)` may belong here
- | |
- | unclosed delimiter
-
-error: expected one of `->`, `;`, `where`, or `{`, found `>`
- --> $DIR/issue-58856-1.rs:3:14
- |
-LL | impl A {
- | - while parsing this item list starting here
-LL |
-LL | fn b(self>
- | ^ expected one of `->`, `;`, `where`, or `{`
-...
-LL | }
- | - the item list ends here
-
-error[E0412]: cannot find type `A` in this scope
- --> $DIR/issue-58856-1.rs:1:6
- |
-LL | impl A {
- | ^ not found in this scope
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0412`.
+++ /dev/null
-struct Empty;
-
-trait Howness {}
-
-impl Howness for () {
- fn how_are_you(&self -> Empty {
- //~^ ERROR expected one of `)` or `,`, found `->`
- //~| ERROR method `how_are_you` is not a member of trait `Howness`
- Empty
- }
-}
-//~^ ERROR non-item in item list
-
-fn main() {}
+++ /dev/null
-error: expected one of `)` or `,`, found `->`
- --> $DIR/issue-58856-2.rs:6:19
- |
-LL | fn how_are_you(&self -> Empty {
- | ^ -^^
- | | |
- | | help: `)` may belong here
- | unclosed delimiter
-
-error: non-item in item list
- --> $DIR/issue-58856-2.rs:11:1
- |
-LL | impl Howness for () {
- | - item list starts here
-...
-LL | }
- | ^
- | |
- | non-item starts here
- | item list ends here
-
-error[E0407]: method `how_are_you` is not a member of trait `Howness`
- --> $DIR/issue-58856-2.rs:6:5
- |
-LL | / fn how_are_you(&self -> Empty {
-LL | |
-LL | |
-LL | | Empty
-LL | | }
- | |_____^ not a member of trait `Howness`
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0407`.
+++ /dev/null
-struct X(i32,i32,i32);
-
-fn main() {
- let a = X(1, 2, 3);
- let b = a.1suffix;
- //~^ ERROR suffixes on a tuple index are invalid
- println!("{}", b);
- let c = (1, 2, 3);
- let d = c.1suffix;
- //~^ ERROR suffixes on a tuple index are invalid
- println!("{}", d);
- let s = X { 0suffix: 0, 1: 1, 2: 2 };
- //~^ ERROR suffixes on a tuple index are invalid
- match s {
- X { 0suffix: _, .. } => {}
- //~^ ERROR suffixes on a tuple index are invalid
- }
-}
+++ /dev/null
-error: suffixes on a tuple index are invalid
- --> $DIR/issue-59418.rs:5:15
- |
-LL | let b = a.1suffix;
- | ^^^^^^^ invalid suffix `suffix`
-
-error: suffixes on a tuple index are invalid
- --> $DIR/issue-59418.rs:9:15
- |
-LL | let d = c.1suffix;
- | ^^^^^^^ invalid suffix `suffix`
-
-error: suffixes on a tuple index are invalid
- --> $DIR/issue-59418.rs:12:17
- |
-LL | let s = X { 0suffix: 0, 1: 1, 2: 2 };
- | ^^^^^^^ invalid suffix `suffix`
-
-error: suffixes on a tuple index are invalid
- --> $DIR/issue-59418.rs:15:13
- |
-LL | X { 0suffix: _, .. } => {}
- | ^^^^^^^ invalid suffix `suffix`
-
-error: aborting due to 4 previous errors
-
+++ /dev/null
-fn main() {}
-
-trait T {
- fn qux() -> Option<usize> {
- let _ = if true {
- });
-//~^ ERROR non-item in item list
-//~| ERROR mismatched closing delimiter: `)`
-//~| ERROR expected one of `.`, `;`
- Some(4)
- }
+++ /dev/null
-error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}`
- --> $DIR/issue-60075.rs:6:10
- |
-LL | });
- | ^ expected one of `.`, `;`, `?`, `else`, or an operator
-
-error: non-item in item list
- --> $DIR/issue-60075.rs:6:11
- |
-LL | trait T {
- | - item list starts here
-...
-LL | });
- | ^ non-item starts here
-...
-LL | }
- | - item list ends here
-
-error: mismatched closing delimiter: `)`
- --> $DIR/issue-60075.rs:4:31
- |
-LL | fn qux() -> Option<usize> {
- | ^ unclosed delimiter
-LL | let _ = if true {
-LL | });
- | ^ mismatched closing delimiter
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// ignore-tidy-trailing-newlines
-// error-pattern: aborting due to 3 previous errors
-#![allow(uncommon_codepoints)]
-
-y![
-Ϥ,
\ No newline at end of file
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62524.rs:6:3
- |
-LL | y![
- | - unclosed delimiter
-LL | Ϥ,
- | ^
-
-error: macros that expand to items must be delimited with braces or followed by a semicolon
- --> $DIR/issue-62524.rs:5:3
- |
-LL | y![
- | ___^
-LL | | Ϥ,
- | |__^
- |
-help: change the delimiters to curly braces
- |
-LL | y! { /* items */ }
- | ~~~~~~~~~~~~~~~
-help: add a semicolon
- |
-LL | Ϥ,;
- | +
-
-error: cannot find macro `y` in this scope
- --> $DIR/issue-62524.rs:5:1
- |
-LL | y![
- | ^
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-pub t(#
-//~^ ERROR missing `fn` or `struct` for function or struct definition
-//~ ERROR this file contains an unclosed delimiter
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62546.rs:3:52
- |
-LL | pub t(#
- | - unclosed delimiter
-LL |
-LL |
- | ^
-
-error: missing `fn` or `struct` for function or struct definition
- --> $DIR/issue-62546.rs:1:4
- |
-LL | pub t(#
- | ---^- help: if you meant to call a macro, try: `t!`
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-// error-pattern:this file contains an unclosed delimiter
-// error-pattern:xpected `{`, found `macro_rules`
-
-fn main() {}
-
-fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62554.rs:6:89
- |
-LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
- | - - - - - ^
- | | | | | |
- | | | | | unclosed delimiter
- | | | | unclosed delimiter
- | | | unclosed delimiter
- | unclosed delimiter unclosed delimiter
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62554.rs:6:89
- |
-LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
- | - - - - - ^
- | | | | | |
- | | | | | unclosed delimiter
- | | | | unclosed delimiter
- | | | unclosed delimiter
- | unclosed delimiter unclosed delimiter
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62554.rs:6:89
- |
-LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
- | - - - - - ^
- | | | | | |
- | | | | | unclosed delimiter
- | | | | unclosed delimiter
- | | | unclosed delimiter
- | unclosed delimiter unclosed delimiter
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62554.rs:6:89
- |
-LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
- | - - - - - ^
- | | | | | |
- | | | | | unclosed delimiter
- | | | | unclosed delimiter
- | | | unclosed delimiter
- | unclosed delimiter unclosed delimiter
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62554.rs:6:89
- |
-LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
- | - - - - - ^
- | | | | | |
- | | | | | unclosed delimiter
- | | | | unclosed delimiter
- | | | unclosed delimiter
- | unclosed delimiter unclosed delimiter
-
-error: expected `{`, found `macro_rules`
- --> $DIR/issue-62554.rs:6:23
- |
-LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
- | -- ^^^^^^^^^^^ expected `{`
- | |
- | this `if` expression has a condition, but no block
- |
-help: try placing this code inside a block
- |
-LL ~ fn foo(u: u8) { if u8 { macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
-LL + }
- |
-
-error: aborting due to 6 previous errors
-
+++ /dev/null
-// Regression test for issue #62660: if a receiver's type does not
-// successfully parse, emit the correct error instead of ICE-ing the compiler.
-
-struct Foo;
-
-impl Foo {
- pub fn foo(_: i32, self: Box<Self) {}
- //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)`
-}
-
-fn main() {}
+++ /dev/null
-error: expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)`
- --> $DIR/issue-62660.rs:7:38
- |
-LL | pub fn foo(_: i32, self: Box<Self) {}
- | ^ expected one of 9 possible tokens
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {}
-
-fn f() -> isize { fn f() -> isize {} pub f<
-//~^ ERROR missing `fn` or `struct` for function or struct definition
-//~| ERROR mismatched types
-//~ ERROR this file contains an unclosed delimiter
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62881.rs:6:52
- |
-LL | fn f() -> isize { fn f() -> isize {} pub f<
- | - unclosed delimiter
-...
-LL |
- | ^
-
-error: missing `fn` or `struct` for function or struct definition
- --> $DIR/issue-62881.rs:3:41
- |
-LL | fn f() -> isize { fn f() -> isize {} pub f<
- | ^
-
-error[E0308]: mismatched types
- --> $DIR/issue-62881.rs:3:29
- |
-LL | fn f() -> isize { fn f() -> isize {} pub f<
- | - ^^^^^ expected `isize`, found `()`
- | |
- | implicitly returns `()` as its body has no tail or `return` expression
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// Regression test for #62894, shouldn't crash.
-// error-pattern: this file contains an unclosed delimiter
-// error-pattern: expected one of `(`, `[`, or `{`, found keyword `fn`
-
-fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
-
-fn main() {}
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62894.rs:7:14
- |
-LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
- | - - - unclosed delimiter
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-LL |
-LL | fn main() {}
- | ^
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62894.rs:7:14
- |
-LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
- | - - - unclosed delimiter
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-LL |
-LL | fn main() {}
- | ^
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62894.rs:7:14
- |
-LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
- | - - - unclosed delimiter
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-LL |
-LL | fn main() {}
- | ^
-
-error: expected one of `(`, `[`, or `{`, found keyword `fn`
- --> $DIR/issue-62894.rs:7:1
- |
-LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
- | - expected one of `(`, `[`, or `{`
-LL |
-LL | fn main() {}
- | ^^ unexpected token
- |
- ::: $SRC_DIR/core/src/macros/mod.rs:LL:COL
- |
-LL | ($left:expr, $right:expr $(,)?) => ({
- | ---------- while parsing argument for this `expr` macro fragment
-
-error: aborting due to 4 previous errors
-
+++ /dev/null
-fn main() {}
-
-fn v() -> isize { //~ ERROR mismatched types
-mod _ { //~ ERROR expected identifier
-pub fn g() -> isizee { //~ ERROR cannot find type `isizee` in this scope
-mod _ { //~ ERROR expected identifier
-pub g() -> is //~ ERROR missing `fn` for function definition
-(), w20);
-}
-(), w20); //~ ERROR expected item, found `;`
-}
+++ /dev/null
-error: expected identifier, found reserved identifier `_`
- --> $DIR/issue-62895.rs:4:5
- |
-LL | mod _ {
- | ^ expected identifier, found reserved identifier
-
-error: expected identifier, found reserved identifier `_`
- --> $DIR/issue-62895.rs:6:5
- |
-LL | mod _ {
- | ^ expected identifier, found reserved identifier
-
-error: missing `fn` for function definition
- --> $DIR/issue-62895.rs:7:4
- |
-LL | pub g() -> is
- | ^^^^
- |
-help: add `fn` here to parse `g` as a public function
- |
-LL | pub fn g() -> is
- | ++
-
-error: expected item, found `;`
- --> $DIR/issue-62895.rs:10:9
- |
-LL | (), w20);
- | ^ help: remove this semicolon
-
-error[E0412]: cannot find type `isizee` in this scope
- --> $DIR/issue-62895.rs:5:15
- |
-LL | pub fn g() -> isizee {
- | ^^^^^^ help: a builtin type with a similar name exists: `isize`
-
-error[E0308]: mismatched types
- --> $DIR/issue-62895.rs:3:11
- |
-LL | fn v() -> isize {
- | - ^^^^^ expected `isize`, found `()`
- | |
- | implicitly returns `()` as its body has no tail or `return` expression
-
-error: aborting due to 6 previous errors
-
-Some errors have detailed explanations: E0308, E0412.
-For more information about an error, try `rustc --explain E0308`.
+++ /dev/null
-"\u\\"
-//~^ ERROR incorrect unicode escape sequence
-//~| ERROR invalid trailing slash in literal
-//~| ERROR expected item, found `"\u\\"`
+++ /dev/null
-error: incorrect unicode escape sequence
- --> $DIR/issue-62913.rs:1:2
- |
-LL | "\u\"
- | ^^^ incorrect unicode escape sequence
- |
- = help: format of unicode escape sequences is `\u{...}`
-
-error: invalid trailing slash in literal
- --> $DIR/issue-62913.rs:1:5
- |
-LL | "\u\"
- | ^ invalid trailing slash in literal
-
-error: expected item, found `"\u\"`
- --> $DIR/issue-62913.rs:1:1
- |
-LL | "\u\"
- | ^^^^^^ expected item
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// ignore-tidy-trailing-newlines
-// error-pattern: aborting due to 7 previous errors
-
-fn main() {}
-
-fn p() { match s { v, E { [) {) }
-
-
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62973.rs:8:2
- |
-LL | fn p() { match s { v, E { [) {) }
- | - - unclosed delimiter
- | |
- | unclosed delimiter
-LL |
-LL |
- | ^
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-62973.rs:8:2
- |
-LL | fn p() { match s { v, E { [) {) }
- | - - unclosed delimiter
- | |
- | unclosed delimiter
-LL |
-LL |
- | ^
-
-error: expected one of `,` or `}`, found `{`
- --> $DIR/issue-62973.rs:6:8
- |
-LL | fn p() { match s { v, E { [) {) }
- | ^ - -^ expected one of `,` or `}`
- | | | |
- | | | help: `}` may belong here
- | | while parsing this struct
- | unclosed delimiter
-
-error: struct literals are not allowed here
- --> $DIR/issue-62973.rs:6:16
- |
-LL | fn p() { match s { v, E { [) {) }
- | ________________^
-LL | |
-LL | |
- | |_^
- |
-help: surround the struct literal with parentheses
- |
-LL ~ fn p() { match (s { v, E { [) {) }
-LL |
-LL ~ )
- |
-
-error: expected one of `.`, `?`, `{`, or an operator, found `}`
- --> $DIR/issue-62973.rs:8:2
- |
-LL | fn p() { match s { v, E { [) {) }
- | ----- while parsing this match expression
-LL |
-LL |
- | ^ expected one of `.`, `?`, `{`, or an operator
-
-error: mismatched closing delimiter: `)`
- --> $DIR/issue-62973.rs:6:27
- |
-LL | fn p() { match s { v, E { [) {) }
- | ^^ mismatched closing delimiter
- | |
- | unclosed delimiter
-
-error: mismatched closing delimiter: `)`
- --> $DIR/issue-62973.rs:6:30
- |
-LL | fn p() { match s { v, E { [) {) }
- | ^^ mismatched closing delimiter
- | |
- | unclosed delimiter
-
-error: aborting due to 7 previous errors
-
+++ /dev/null
-// check-pass
-
-#![feature(exclusive_range_pattern)]
-#![feature(half_open_range_patterns)]
-
-#![allow(ellipsis_inclusive_range_patterns)]
-
-fn main() {
- macro_rules! mac_expr {
- ($e:expr) => {
- if let 2...$e = 3 {}
- if let 2..=$e = 3 {}
- if let 2..$e = 3 {}
- if let ..$e = 3 {}
- if let ..=$e = 3 {}
- if let $e.. = 5 {}
- if let $e..5 = 4 {}
- if let $e..=5 = 4 {}
- }
- }
- mac_expr!(4);
-}
+++ /dev/null
-// fixed by #66361
-// error-pattern: aborting due to 3 previous errors
-impl W <s(f;Y(;]
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-63116.rs:3:18
- |
-LL | impl W <s(f;Y(;]
- | - ^
- | |
- | unclosed delimiter
-
-error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;`
- --> $DIR/issue-63116.rs:3:12
- |
-LL | impl W <s(f;Y(;]
- | ^ expected one of 7 possible tokens
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-63116.rs:3:14
- |
-LL | impl W <s(f;Y(;]
- | ^ ^ mismatched closing delimiter
- | |
- | unclosed delimiter
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// error-pattern: aborting due to 5 previous errors
-
-fn i(n{...,f #
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-63135.rs:3:16
- |
-LL | fn i(n{...,f #
- | - - ^
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-63135.rs:3:16
- |
-LL | fn i(n{...,f #
- | - - ^
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-
-error: expected field pattern, found `...`
- --> $DIR/issue-63135.rs:3:8
- |
-LL | fn i(n{...,f #
- | ^^^ help: to omit remaining fields, use one fewer `.`: `..`
-
-error: expected `}`, found `,`
- --> $DIR/issue-63135.rs:3:11
- |
-LL | fn i(n{...,f #
- | ---^
- | | |
- | | expected `}`
- | `..` must be at the end and cannot have a trailing comma
-
-error: expected one of `!` or `[`, found `}`
- --> $DIR/issue-63135.rs:3:16
- |
-LL | fn i(n{...,f #
- | - ^ expected one of `!` or `[`
- | |
- | while parsing the fields for this pattern
-
-error: aborting due to 5 previous errors
-
+++ /dev/null
-#![allow(unused)]
-fn main() {
- let _foo = b'hello\0';
- //~^ ERROR character literal may only contain one codepoint
- //~| HELP if you meant to write a byte string literal, use double quotes
- let _bar = 'hello';
- //~^ ERROR character literal may only contain one codepoint
- //~| HELP if you meant to write a `str` literal, use double quotes
-}
+++ /dev/null
-error: character literal may only contain one codepoint
- --> $DIR/issue-64732.rs:3:16
- |
-LL | let _foo = b'hello\0';
- | ^^^^^^^^^^
- |
-help: if you meant to write a byte string literal, use double quotes
- |
-LL | let _foo = b"hello\0";
- | ~~~~~~~~~~
-
-error: character literal may only contain one codepoint
- --> $DIR/issue-64732.rs:6:16
- |
-LL | let _bar = 'hello';
- | ^^^^^^^
- |
-help: if you meant to write a `str` literal, use double quotes
- |
-LL | let _bar = "hello";
- | ~~~~~~~
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-// check-pass
-
-// Here we check that a `:vis` macro matcher subsititued for the empty visibility
-// (`VisibilityKind::Inherited`) is accepted when used before an enum variant.
-
-fn main() {}
-
-macro_rules! mac_variant {
- ($vis:vis MARKER) => {
- enum Enum {
- $vis Unit,
-
- $vis Tuple(u8, u16),
-
- $vis Struct { f: u8 },
- }
- }
-}
-
-mac_variant!(MARKER);
-
-// We also accept visibilities on variants syntactically but not semantically.
-#[cfg(FALSE)]
-enum E {
- pub U,
- pub(crate) T(u8),
- pub(super) T { f: String }
-}
+++ /dev/null
-// check-pass
-
-// Here we check that a `:vis` macro matcher subsititued for the empty visibility
-// (`VisibilityKind::Inherited`) is accepted when used before an item in a trait.
-
-fn main() {}
-
-macro_rules! mac_in_trait {
- ($vis:vis MARKER) => {
- $vis fn beta() {}
-
- $vis const GAMMA: u8;
-
- $vis type Delta;
- }
-}
-
-trait Alpha {
- mac_in_trait!(MARKER);
-}
-
-// We also accept visibilities on items in traits syntactically but not semantically.
-#[cfg(FALSE)]
-trait Foo {
- pub fn bar();
- pub(crate) type baz;
- pub(super) const QUUX: u8;
-}
+++ /dev/null
-// Regression test; used to ICE with 'visit_mac_call disabled by default' due to a
-// `MutVisitor` in `fn make_all_value_bindings_mutable` (`parse/parser/pat.rs`).
-
-macro_rules! mac1 {
- ($eval:expr) => {
- let mut $eval = ();
- //~^ ERROR `mut` must be followed by a named binding
- };
-}
-
-macro_rules! mac2 {
- ($eval:pat) => {
- let mut $eval = ();
- //~^ ERROR `mut` must be followed by a named binding
- //~| ERROR expected identifier, found `does_not_exist!()`
- };
-}
-
-fn foo() {
- mac1! { does_not_exist!() }
- //~^ ERROR cannot find macro `does_not_exist` in this scope
- mac2! { does_not_exist!() }
- //~^ ERROR cannot find macro `does_not_exist` in this scope
-}
-
-fn main() {}
+++ /dev/null
-error: `mut` must be followed by a named binding
- --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:6:13
- |
-LL | let mut $eval = ();
- | ^^^^^^^^^ help: remove the `mut` prefix: `does_not_exist!()`
-...
-LL | mac1! { does_not_exist!() }
- | --------------------------- in this macro invocation
- |
- = note: `mut` may be followed by `variable` and `variable @ pattern`
- = note: this error originates in the macro `mac1` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: expected identifier, found `does_not_exist!()`
- --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:17
- |
-LL | let mut $eval = ();
- | ^^^^^ expected identifier
-...
-LL | mac2! { does_not_exist!() }
- | --------------------------- in this macro invocation
- |
- = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: `mut` must be followed by a named binding
- --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:13
- |
-LL | let mut $eval = ();
- | ^^^ help: remove the `mut` prefix: `does_not_exist!()`
-...
-LL | mac2! { does_not_exist!() }
- | --------------------------- in this macro invocation
- |
- = note: `mut` may be followed by `variable` and `variable @ pattern`
- = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: cannot find macro `does_not_exist` in this scope
- --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:22:13
- |
-LL | mac2! { does_not_exist!() }
- | ^^^^^^^^^^^^^^
-
-error: cannot find macro `does_not_exist` in this scope
- --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:20:13
- |
-LL | mac1! { does_not_exist!() }
- | ^^^^^^^^^^^^^^
-
-error: aborting due to 5 previous errors
-
+++ /dev/null
-fn main() {
- auto n = 0;//~ ERROR invalid variable declaration
- //~^ HELP write `let` instead of `auto` to introduce a new variable
- auto m;//~ ERROR invalid variable declaration
- //~^ HELP write `let` instead of `auto` to introduce a new variable
- m = 0;
-
- var n = 0;//~ ERROR invalid variable declaration
- //~^ HELP write `let` instead of `var` to introduce a new variable
- var m;//~ ERROR invalid variable declaration
- //~^ HELP write `let` instead of `var` to introduce a new variable
- m = 0;
-
- mut n = 0;//~ ERROR invalid variable declaration
- //~^ HELP missing keyword
- mut var;//~ ERROR invalid variable declaration
- //~^ HELP missing keyword
- var = 0;
-
- let _recovery_witness: () = 0; //~ ERROR mismatched types
-}
+++ /dev/null
-error: invalid variable declaration
- --> $DIR/issue-65257-invalid-var-decl-recovery.rs:2:5
- |
-LL | auto n = 0;
- | ^^^^
- |
-help: write `let` instead of `auto` to introduce a new variable
- |
-LL | let n = 0;
- | ~~~
-
-error: invalid variable declaration
- --> $DIR/issue-65257-invalid-var-decl-recovery.rs:4:5
- |
-LL | auto m;
- | ^^^^
- |
-help: write `let` instead of `auto` to introduce a new variable
- |
-LL | let m;
- | ~~~
-
-error: invalid variable declaration
- --> $DIR/issue-65257-invalid-var-decl-recovery.rs:8:5
- |
-LL | var n = 0;
- | ^^^
- |
-help: write `let` instead of `var` to introduce a new variable
- |
-LL | let n = 0;
- | ~~~
-
-error: invalid variable declaration
- --> $DIR/issue-65257-invalid-var-decl-recovery.rs:10:5
- |
-LL | var m;
- | ^^^
- |
-help: write `let` instead of `var` to introduce a new variable
- |
-LL | let m;
- | ~~~
-
-error: invalid variable declaration
- --> $DIR/issue-65257-invalid-var-decl-recovery.rs:14:5
- |
-LL | mut n = 0;
- | ^^^ help: missing keyword: `let mut`
-
-error: invalid variable declaration
- --> $DIR/issue-65257-invalid-var-decl-recovery.rs:16:5
- |
-LL | mut var;
- | ^^^ help: missing keyword: `let mut`
-
-error[E0308]: mismatched types
- --> $DIR/issue-65257-invalid-var-decl-recovery.rs:20:33
- |
-LL | let _recovery_witness: () = 0;
- | -- ^ expected `()`, found integer
- | |
- | expected due to this
-
-error: aborting due to 7 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// run-pass
-
-// Test that failing macro matchers will not cause pre-expansion errors
-// even though they use a feature that is pre-expansion gated.
-
-macro_rules! m {
- ($e:expr) => { 0 }; // This fails on the input below due to `, foo`.
- ($e:expr,) => { 1 }; // This also fails to match due to `foo`.
- (box $e:expr, foo) => { 2 }; // Successful matcher, we should get `2`.
-}
-
-fn main() {
- assert_eq!(2, m!(box 42, foo));
-}
+++ /dev/null
-trait Foo { fn a() } //~ ERROR expected one of `->`, `;`, `where`, or `{`, found `}`
-
-fn main() {}
+++ /dev/null
-error: expected one of `->`, `;`, `where`, or `{`, found `}`
- --> $DIR/issue-6610.rs:1:20
- |
-LL | trait Foo { fn a() }
- | - ^ expected one of `->`, `;`, `where`, or `{`
- | |
- | while parsing this `fn`
-
-error: aborting due to previous error
-
+++ /dev/null
-// The problem in #66357 was that the call trace:
-//
-// - parse_fn_block_decl
-// - expect_or
-// - unexpected
-// - expect_one_of
-// - expected_one_of_not_found
-// - recover_closing_delimiter
-//
-// ended up bubbling up `Ok(true)` to `unexpected` which then used `unreachable!()`.
-
-fn f() { |[](* }
-//~^ ERROR expected one of `,` or `:`, found `(`
-//~| ERROR expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*`
+++ /dev/null
-error: expected one of `,` or `:`, found `(`
- --> $DIR/issue-66357-unexpected-unreachable.rs:12:13
- |
-LL | fn f() { |[](* }
- | ^ expected one of `,` or `:`
-
-error: expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*`
- --> $DIR/issue-66357-unexpected-unreachable.rs:12:13
- |
-LL | fn f() { |[](* }
- | ^^ help: `)` may belong here
- | |
- | unclosed delimiter
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-// run-rustfix
-
-// In this regression test for #67146, we check that the
-// negative outlives bound `!'a` is rejected by the parser.
-// This regression was first introduced in PR #57364.
-
-fn main() {}
-
-pub fn f1<T>() {}
-//~^ ERROR negative bounds are not supported
-pub fn f2<'a, T: Ord>() {}
-//~^ ERROR negative bounds are not supported
-pub fn f3<'a, T: Ord>() {}
-//~^ ERROR negative bounds are not supported
+++ /dev/null
-// run-rustfix
-
-// In this regression test for #67146, we check that the
-// negative outlives bound `!'a` is rejected by the parser.
-// This regression was first introduced in PR #57364.
-
-fn main() {}
-
-pub fn f1<T: !'static>() {}
-//~^ ERROR negative bounds are not supported
-pub fn f2<'a, T: Ord + !'a>() {}
-//~^ ERROR negative bounds are not supported
-pub fn f3<'a, T: !'a + Ord>() {}
-//~^ ERROR negative bounds are not supported
+++ /dev/null
-error: negative bounds are not supported
- --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:12
- |
-LL | pub fn f1<T: !'static>() {}
- | ^^^^^^^^^^ negative bounds are not supported
-
-error: negative bounds are not supported
- --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:11:22
- |
-LL | pub fn f2<'a, T: Ord + !'a>() {}
- | ^^^^^ negative bounds are not supported
-
-error: negative bounds are not supported
- --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:13:16
- |
-LL | pub fn f3<'a, T: !'a + Ord>() {}
- | ^^^^^ negative bounds are not supported
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-mod a {
- use std::marker::PhantomData;
-
- enum Bug {
- V = [PhantomData; { [ () ].len() ].len() as isize,
- //~^ ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- }
-}
-
-mod b {
- enum Bug {
- V = [Vec::new; { [].len() ].len() as isize,
- //~^ ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR type annotations needed
- }
-}
-
-mod c {
- enum Bug {
- V = [Vec::new; { [0].len() ].len() as isize,
- //~^ ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR mismatched closing delimiter: `]`
- //~| ERROR type annotations needed
- }
-}
-
-fn main() {}
+++ /dev/null
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
- |
-LL | V = [PhantomData; { [ () ].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
- |
-LL | V = [Vec::new; { [].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
- |
-LL | V = [Vec::new; { [0].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
- |
-LL | V = [PhantomData; { [ () ].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
- |
-LL | V = [Vec::new; { [].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
- |
-LL | V = [Vec::new; { [0].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
- |
-LL | V = [PhantomData; { [ () ].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
- |
-LL | V = [Vec::new; { [].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
- |
-LL | V = [Vec::new; { [0].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
- |
-LL | V = [PhantomData; { [ () ].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
- |
-LL | V = [Vec::new; { [].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error: mismatched closing delimiter: `]`
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
- |
-LL | V = [Vec::new; { [0].len() ].len() as isize,
- | - ^ ^ mismatched closing delimiter
- | | |
- | | unclosed delimiter
- | closing delimiter possibly meant for this
-
-error[E0282]: type annotations needed
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:29
- |
-LL | V = [Vec::new; { [].len() ].len() as isize,
- | ^^^ cannot infer type for type parameter `T`
-
-error[E0282]: type annotations needed
- --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:14
- |
-LL | V = [Vec::new; { [0].len() ].len() as isize,
- | ^^^^^^^^ cannot infer type for type parameter `T`
-
-error: aborting due to 14 previous errors
-
-For more information about this error, try `rustc --explain E0282`.
+++ /dev/null
-pub struct Foo {
- pub bar: Vec<i32>ö
- //~^ ERROR expected `,`, or `}`, found `ö`
-} //~ ERROR expected `:`, found `}`
-
-fn main() {}
+++ /dev/null
-error: expected `,`, or `}`, found `ö`
- --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:2:22
- |
-LL | pub bar: Vec<i32>ö
- | ^ help: try adding a comma: `,`
-
-error: expected `:`, found `}`
- --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:4:1
- |
-LL | pub bar: Vec<i32>ö
- | - expected `:`
-LL |
-LL | }
- | ^ unexpected token
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-// Make sure we don't propagate restrictions on trait impl items to items inside them.
-
-// check-pass
-// edition:2018
-
-fn main() {}
-
-trait X {
- fn foo();
-}
-
-impl X for () {
- fn foo() {
- struct S;
- impl S {
- pub const X: u8 = 0;
- pub const fn bar() {}
- async fn qux() {}
- }
- }
-}
+++ /dev/null
-fn main() {}
-
-type X<'a> = (?'a) +;
-//~^ ERROR `?` may only modify trait bounds, not lifetime bounds
-//~| ERROR at least one trait is required for an object type
-//~| WARN trait objects without an explicit `dyn` are deprecated
-//~| WARN this is accepted in the current edition
+++ /dev/null
-error: `?` may only modify trait bounds, not lifetime bounds
- --> $DIR/issue-68890-2.rs:3:15
- |
-LL | type X<'a> = (?'a) +;
- | ^
-
-warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-68890-2.rs:3:14
- |
-LL | type X<'a> = (?'a) +;
- | ^^^^^^^ help: use `dyn`: `dyn (?'a) +`
- |
- = note: `#[warn(bare_trait_objects)]` on by default
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
-
-error[E0224]: at least one trait is required for an object type
- --> $DIR/issue-68890-2.rs:3:14
- |
-LL | type X<'a> = (?'a) +;
- | ^^^^^^^
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0224`.
+++ /dev/null
-enum e{A((?'a a+?+l))}
-//~^ ERROR `?` may only modify trait bounds, not lifetime bounds
-//~| ERROR expected one of `)`, `+`, or `,`
-//~| ERROR expected item, found `)`
+++ /dev/null
-error: `?` may only modify trait bounds, not lifetime bounds
- --> $DIR/issue-68890.rs:1:11
- |
-LL | enum e{A((?'a a+?+l))}
- | ^
-
-error: expected one of `)`, `+`, or `,`, found `a`
- --> $DIR/issue-68890.rs:1:15
- |
-LL | enum e{A((?'a a+?+l))}
- | ^ expected one of `)`, `+`, or `,`
-
-error: expected item, found `)`
- --> $DIR/issue-68890.rs:1:21
- |
-LL | enum e{A((?'a a+?+l))}
- | ^ expected item
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// check-pass
-
-macro_rules! foo {
- ($a:literal) => {
- bar!($a)
- };
-}
-
-macro_rules! bar {
- ($b:literal) => {};
-}
-
-fn main() {
- foo!(-2);
- bar!(-2);
-}
+++ /dev/null
-struct Foo(i32);
-
-fn main() {
- let Foo(...) = Foo(0); //~ ERROR unexpected `...`
- let [_, ..., _] = [0, 1]; //~ ERROR unexpected `...`
- let _recovery_witness: () = 0; //~ ERROR mismatched types
-}
+++ /dev/null
-error: unexpected `...`
- --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:4:13
- |
-LL | let Foo(...) = Foo(0);
- | ^^^
- | |
- | not a valid pattern
- | help: for a rest pattern, use `..` instead of `...`
-
-error: unexpected `...`
- --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:5:13
- |
-LL | let [_, ..., _] = [0, 1];
- | ^^^
- | |
- | not a valid pattern
- | help: for a rest pattern, use `..` instead of `...`
-
-error[E0308]: mismatched types
- --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:6:33
- |
-LL | let _recovery_witness: () = 0;
- | -- ^ expected `()`, found integer
- | |
- | expected due to this
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// run-rustfix
-// This is for checking if we can apply suggestions as-is.
-
-pub struct Foo(i32);
-
-fn main() {
- let Foo(..) = Foo(0); //~ ERROR unexpected `...`
- let [_, .., _] = [0, 1]; //~ ERROR unexpected `...`
-}
+++ /dev/null
-// run-rustfix
-// This is for checking if we can apply suggestions as-is.
-
-pub struct Foo(i32);
-
-fn main() {
- let Foo(...) = Foo(0); //~ ERROR unexpected `...`
- let [_, ..., _] = [0, 1]; //~ ERROR unexpected `...`
-}
+++ /dev/null
-error: unexpected `...`
- --> $DIR/issue-70388-without-witness.rs:7:13
- |
-LL | let Foo(...) = Foo(0);
- | ^^^
- | |
- | not a valid pattern
- | help: for a rest pattern, use `..` instead of `...`
-
-error: unexpected `...`
- --> $DIR/issue-70388-without-witness.rs:8:13
- |
-LL | let [_, ..., _] = [0, 1];
- | ^^^
- | |
- | not a valid pattern
- | help: for a rest pattern, use `..` instead of `...`
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-struct S {}
-
-impl S {
- fn foo(&mur Self) {}
- //~^ ERROR expected identifier, found keyword `Self`
- //~| ERROR expected one of `:`, `@`
- //~| ERROR the `Self` constructor can only be used with
- fn bar(&'static mur Self) {}
- //~^ ERROR unexpected lifetime
- //~| ERROR expected identifier, found keyword `Self`
- //~| ERROR expected one of `:`, `@`
- //~| ERROR the `Self` constructor can only be used with
-
- fn baz(&mur Self @ _) {}
- //~^ ERROR expected one of `:`, `@`
-}
-
-fn main() {}
+++ /dev/null
-error: expected identifier, found keyword `Self`
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17
- |
-LL | fn foo(&mur Self) {}
- | ^^^^ expected identifier, found keyword
-
-error: expected one of `:`, `@`, or `|`, found keyword `Self`
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17
- |
-LL | fn foo(&mur Self) {}
- | -----^^^^
- | | |
- | | expected one of `:`, `@`, or `|`
- | help: declare the type after the parameter binding: `<identifier>: <type>`
-
-error: unexpected lifetime `'static` in pattern
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:13
- |
-LL | fn bar(&'static mur Self) {}
- | ^^^^^^^ help: remove the lifetime
-
-error: expected identifier, found keyword `Self`
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25
- |
-LL | fn bar(&'static mur Self) {}
- | ^^^^ expected identifier, found keyword
-
-error: expected one of `:`, `@`, or `|`, found keyword `Self`
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25
- |
-LL | fn bar(&'static mur Self) {}
- | -------------^^^^
- | | |
- | | expected one of `:`, `@`, or `|`
- | help: declare the type after the parameter binding: `<identifier>: <type>`
-
-error: expected one of `:`, `@`, or `|`, found keyword `Self`
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:14:17
- |
-LL | fn baz(&mur Self @ _) {}
- | ^^^^ expected one of `:`, `@`, or `|`
-
-error: the `Self` constructor can only be used with tuple or unit structs
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17
- |
-LL | fn foo(&mur Self) {}
- | ^^^^ help: use curly brackets: `Self { /* fields */ }`
-
-error: the `Self` constructor can only be used with tuple or unit structs
- --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25
- |
-LL | fn bar(&'static mur Self) {}
- | ^^^^ help: use curly brackets: `Self { /* fields */ }`
-
-error: aborting due to 8 previous errors
-
+++ /dev/null
-fn main() {
- expr as fun()(:); //~ ERROR expected expression
-}
+++ /dev/null
-error: expected expression, found `:`
- --> $DIR/issue-70552-ascription-in-parens-after-call.rs:2:19
- |
-LL | expr as fun()(:);
- | ^ expected expression
-
-error: aborting due to previous error
-
+++ /dev/null
-pub enum ErrorHandled {
- Reported,
- TooGeneric,
-}
-
-impl ErrorHandled {
- pub fn assert_reported(self) {
- match self {
- ErrorHandled::Reported => {}
- ErrorHandled::TooGeneric => panic!(),
- }
- }
-}
-
-fn struct_generic(x: Vec<i32>) {
- for v in x {
- println!("{}", v);
- }
- }
-} //~ ERROR unexpected closing delimiter: `}`
+++ /dev/null
-error: unexpected closing delimiter: `}`
- --> $DIR/issue-70583-block-is-empty-1.rs:20:1
- |
-LL | fn struct_generic(x: Vec<i32>) {
- | - this opening brace...
-...
-LL | }
- | - ...matches this closing brace
-LL | }
- | ^ unexpected closing delimiter
-
-error: aborting due to previous error
-
+++ /dev/null
-pub enum ErrorHandled {
- Reported,
- TooGeneric,
-}
-
-impl ErrorHandled {
- pub fn assert_reported(self) {
- match self {
- ErrorHandled::Reported => {}}
- //^~ ERROR block is empty, you might have not meant to close it
- ErrorHandled::TooGeneric => panic!(),
- }
- }
-} //~ ERROR unexpected closing delimiter: `}`
+++ /dev/null
-error: unexpected closing delimiter: `}`
- --> $DIR/issue-70583-block-is-empty-2.rs:14:1
- |
-LL | ErrorHandled::Reported => {}}
- | -- block is empty, you might have not meant to close it
-...
-LL | }
- | ^ unexpected closing delimiter
-
-error: aborting due to previous error
-
+++ /dev/null
-// run-pass
-// pretty-expanded FIXME #23616
-#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620
-
-pub fn main() {
- const FOO: f64 = 10.0;
-
- match 0.0 {
- 0.0 ..= FOO => (),
- _ => ()
- }
-}
+++ /dev/null
-fn main() {
- let a = std::process::Command::new("echo")
- .arg("1")
- ,arg("2") //~ ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `,`
- .output();
-}
+++ /dev/null
-error: expected one of `.`, `;`, `?`, `else`, or an operator, found `,`
- --> $DIR/issue-72253.rs:4:9
- |
-LL | .arg("1")
- | - expected one of `.`, `;`, `?`, `else`, or an operator
-LL | ,arg("2")
- | ^ unexpected token
-
-error: aborting due to previous error
-
+++ /dev/null
-fn foo(c: &[u32], n: u32) -> u32 {
- match *c {
- [h, ..] if h > n => 0,
- [h, ..] if h == n => 1,
- [h, ref ts..] => foo(c, n - h) + foo(ts, n),
- //~^ ERROR expected one of `,`, `@`, `]`, or `|`, found `..`
- [] => 0,
- }
-}
+++ /dev/null
-error: expected one of `,`, `@`, `]`, or `|`, found `..`
- --> $DIR/issue-72373.rs:5:19
- |
-LL | [h, ref ts..] => foo(c, n - h) + foo(ts, n),
- | ^^ expected one of `,`, `@`, `]`, or `|`
- |
-help: if you meant to bind the contents of the rest of the array pattern into `ts`, use `@`
- |
-LL | [h, ref ts @ ..] => foo(c, n - h) + foo(ts, n),
- | +
-
-error: aborting due to previous error
-
+++ /dev/null
-#![crate_type="lib"]
-fn x<'a>(x: &mut 'a i32){} //~ ERROR lifetime must precede `mut`
-
-macro_rules! mac {
- ($lt:lifetime) => {
- fn w<$lt>(w: &mut $lt i32) {}
- //~^ ERROR lifetime must precede `mut`
- }
-}
-
-mac!('a);
-
-// avoid false positives
-fn y<'a>(y: &mut 'a + Send) {
- //~^ ERROR expected a path on the left-hand side of `+`, not `&mut 'a`
- //~| WARNING trait objects without an explicit `dyn` are deprecated
- //~| WARN this is accepted in the current edition
- //~| ERROR at least one trait is required for an object type
- let z = y as &mut 'a + Send;
- //~^ ERROR expected value, found trait `Send`
- //~| WARNING trait objects without an explicit `dyn` are deprecated
- //~| WARN this is accepted in the current edition
-}
+++ /dev/null
-error: lifetime must precede `mut`
- --> $DIR/issue-73568-lifetime-after-mut.rs:2:13
- |
-LL | fn x<'a>(x: &mut 'a i32){}
- | ^^^^^^^ help: place the lifetime before `mut`: `&'a mut`
-
-error[E0178]: expected a path on the left-hand side of `+`, not `&mut 'a`
- --> $DIR/issue-73568-lifetime-after-mut.rs:14:13
- |
-LL | fn y<'a>(y: &mut 'a + Send) {
- | ^^^^^^^^^^^^^^ help: try adding parentheses: `&mut ('a + Send)`
-
-error: lifetime must precede `mut`
- --> $DIR/issue-73568-lifetime-after-mut.rs:6:22
- |
-LL | fn w<$lt>(w: &mut $lt i32) {}
- | ^^^^^^^^ help: place the lifetime before `mut`: `&$lt mut`
-...
-LL | mac!('a);
- | -------- in this macro invocation
- |
- = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error[E0423]: expected value, found trait `Send`
- --> $DIR/issue-73568-lifetime-after-mut.rs:19:28
- |
-LL | let z = y as &mut 'a + Send;
- | ^^^^ not a value
-
-warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-73568-lifetime-after-mut.rs:14:18
- |
-LL | fn y<'a>(y: &mut 'a + Send) {
- | ^^ help: use `dyn`: `dyn 'a`
- |
- = note: `#[warn(bare_trait_objects)]` on by default
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
-
-warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-73568-lifetime-after-mut.rs:19:23
- |
-LL | let z = y as &mut 'a + Send;
- | ^^ help: use `dyn`: `dyn 'a`
- |
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
-
-error[E0224]: at least one trait is required for an object type
- --> $DIR/issue-73568-lifetime-after-mut.rs:14:18
- |
-LL | fn y<'a>(y: &mut 'a + Send) {
- | ^^
-
-error: aborting due to 5 previous errors; 2 warnings emitted
-
-Some errors have detailed explanations: E0178, E0224, E0423.
-For more information about an error, try `rustc --explain E0178`.
+++ /dev/null
-// check-pass
-#![allow(non_upper_case_globals)]
-
-const or: usize = 1;
-const and: usize = 2;
-
-mod or {
- pub const X: usize = 3;
-}
-
-mod and {
- pub const X: usize = 4;
-}
-
-fn main() {
- match 0 {
- 0 => {}
- or => {}
- and => {}
- or::X => {}
- and::X => {}
- _ => {}
- }
-}
+++ /dev/null
-// edition:2018
-
-mod t {
- async pub fn t() {}
- //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
- //~| HELP visibility `pub` must come before `async`
-}
+++ /dev/null
-error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
- --> $DIR/issue-76437-async.rs:4:11
- |
-LL | async pub fn t() {}
- | ------^^^
- | | |
- | | expected one of `extern`, `fn`, or `unsafe`
- | help: visibility `pub` must come before `async`: `pub async`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-mod t {
- const async unsafe pub fn t() {}
- //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
- //~| HELP visibility `pub` must come before `const async unsafe`
-}
+++ /dev/null
-error: expected one of `extern` or `fn`, found keyword `pub`
- --> $DIR/issue-76437-const-async-unsafe.rs:4:24
- |
-LL | const async unsafe pub fn t() {}
- | -------------------^^^
- | | |
- | | expected one of `extern` or `fn`
- | help: visibility `pub` must come before `const async unsafe`: `pub const async unsafe`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-mod t {
- const async pub fn t() {}
- //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
- //~| HELP visibility `pub` must come before `const async`
-}
+++ /dev/null
-error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
- --> $DIR/issue-76437-const-async.rs:4:17
- |
-LL | const async pub fn t() {}
- | ------------^^^
- | | |
- | | expected one of `extern`, `fn`, or `unsafe`
- | help: visibility `pub` must come before `const async`: `pub const async`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-mod t {
- const pub fn t() {}
- //~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
- //~| HELP visibility `pub` must come before `const`
-}
+++ /dev/null
-error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
- --> $DIR/issue-76437-const.rs:4:11
- |
-LL | const pub fn t() {}
- | ------^^^
- | | |
- | | expected one of `async`, `extern`, `fn`, or `unsafe`
- | help: visibility `pub` must come before `const`: `pub const`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-mod t {
- unsafe pub(crate) fn t() {}
- //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
- //~| HELP visibility `pub(crate)` must come before `unsafe`
-}
+++ /dev/null
-error: expected one of `extern` or `fn`, found keyword `pub`
- --> $DIR/issue-76437-pub-crate-unsafe.rs:4:12
- |
-LL | unsafe pub(crate) fn t() {}
- | -------^^^-------
- | | |
- | | expected one of `extern` or `fn`
- | help: visibility `pub(crate)` must come before `unsafe`: `pub(crate) unsafe`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-mod t {
- unsafe pub fn t() {}
- //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
- //~| HELP visibility `pub` must come before `unsafe`
-}
+++ /dev/null
-error: expected one of `extern` or `fn`, found keyword `pub`
- --> $DIR/issue-76437-unsafe.rs:4:12
- |
-LL | unsafe pub fn t() {}
- | -------^^^
- | | |
- | | expected one of `extern` or `fn`
- | help: visibility `pub` must come before `unsafe`: `pub unsafe`
-
-error: aborting due to previous error
-
+++ /dev/null
-// run-rustfix
-
-#![allow(dead_code)]
-#![allow(unused_variables)]
-fn f(
- x: u8,
- y: u8,
-) {}
-//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
-
-fn main() {}
+++ /dev/null
-// run-rustfix
-
-#![allow(dead_code)]
-#![allow(unused_variables)]
-fn f(
- x: u8
- y: u8,
-) {}
-//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
-
-fn main() {}
+++ /dev/null
-error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
- --> $DIR/issue-76597.rs:7:38
- |
-LL | ... x: u8
- | -
- | |
- | expected one of 7 possible tokens
- | help: missing `,`
-LL | ... y: u8,
- | ^ unexpected token
-
-error: aborting due to previous error
-
+++ /dev/null
-fn main() {}
-
-macro_rules! test {}
-//~^ ERROR unexpected end of macro invocation
+++ /dev/null
-error: unexpected end of macro invocation
- --> $DIR/issue-7970b.rs:3:1
- |
-LL | macro_rules! test {}
- | ^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
-
-error: aborting due to previous error
-
+++ /dev/null
-trait T { const
-impl //~ ERROR: expected identifier, found keyword `impl`
-}
-
-fn main() {}
+++ /dev/null
-error: expected identifier, found keyword `impl`
- --> $DIR/issue-81806.rs:2:1
- |
-LL | trait T { const
- | - while parsing this item list starting here
-LL | impl
- | ^^^^ expected identifier, found keyword
-LL | }
- | - the item list ends here
- |
-help: you can escape reserved keywords to use them as identifiers
- |
-LL | r#impl
- | ~~~~~~
-
-error: aborting due to previous error
-
+++ /dev/null
-// check-fail
-// ignore-tidy-tab
-
-fn main() {
- """ " //~ ERROR
-}
+++ /dev/null
-error: expected one of `.`, `;`, `?`, `}`, or an operator, found `" "`
- --> $DIR/issue-83639.rs:5:7
- |
-LL | """ "
- | ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
-
-error: aborting due to previous error
-
+++ /dev/null
-// error-pattern: this file contains an unclosed delimiter
-// error-pattern: expected one of
-#[i=i::<ښܖ<
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-84104.rs:3:13
- |
-LL | #[i=i::<ښܖ<
- | - ^
- | |
- | unclosed delimiter
-
-error: expected one of `>`, a const expression, lifetime, or type, found `]`
- --> $DIR/issue-84104.rs:3:13
- |
-LL | #[i=i::<ښܖ<
- | ^ expected one of `>`, a const expression, lifetime, or type
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-fn main() {
- let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- //~^ ERROR expected one of `>`, a const expression
- //~| ERROR expected one of `>`, a const expression, lifetime, or type, found `}`
- //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
- //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
- //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
-}
-//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `}`
+++ /dev/null
-error: expected one of `>`, a const expression, lifetime, or type, found `}`
- --> $DIR/issue-84117.rs:2:67
- |
-LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ------------ ^ expected one of `>`, a const expression, lifetime, or type
- | | |
- | | help: use `=` if you meant to assign
- | while parsing the type for `inner_local`
-
-error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
- --> $DIR/issue-84117.rs:2:65
- |
-LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ^ expected one of 8 possible tokens
-
-error: expected one of `,`, `:`, `=`, or `>`, found `}`
- --> $DIR/issue-84117.rs:8:1
- |
-LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ------------ help: use `=` if you meant to assign - expected one of `,`, `:`, `=`, or `>`
- | |
- | while parsing the type for `outer_local`
-...
-LL | }
- | ^ unexpected token
-
-error: expected one of `>`, a const expression, lifetime, or type, found `}`
- --> $DIR/issue-84117.rs:2:67
- |
-LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ------------ ^ expected one of `>`, a const expression, lifetime, or type
- | | |
- | | help: use `=` if you meant to assign
- | while parsing the type for `inner_local`
-
-error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
- --> $DIR/issue-84117.rs:2:65
- |
-LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ^ expected one of 8 possible tokens
-
-error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
- --> $DIR/issue-84117.rs:2:33
- |
-LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ^ expected one of 8 possible tokens
-
-error: aborting due to 6 previous errors
-
+++ /dev/null
-fn f(t:for<>t?)
-//~^ ERROR: expected parameter name
-//~| ERROR: expected one of
-//~| ERROR: expected one of
+++ /dev/null
-error: expected parameter name, found `?`
- --> $DIR/issue-84148-1.rs:1:14
- |
-LL | fn f(t:for<>t?)
- | ^ expected parameter name
-
-error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
- --> $DIR/issue-84148-1.rs:1:14
- |
-LL | fn f(t:for<>t?)
- | ^
- | |
- | expected one of `(`, `)`, `+`, `,`, `::`, or `<`
- | help: missing `,`
-
-error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
- --> $DIR/issue-84148-1.rs:1:15
- |
-LL | fn f(t:for<>t?)
- | ^ expected one of `->`, `;`, `where`, or `{`
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// error-pattern: this file contains an unclosed delimiter
-// error-pattern: expected parameter name
-// error-pattern: expected one of
-fn f(t:for<>t?
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-84148-2.rs:4:16
- |
-LL | fn f(t:for<>t?
- | - ^
- | |
- | unclosed delimiter
-
-error: expected parameter name, found `?`
- --> $DIR/issue-84148-2.rs:4:14
- |
-LL | fn f(t:for<>t?
- | ^ expected parameter name
-
-error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
- --> $DIR/issue-84148-2.rs:4:14
- |
-LL | fn f(t:for<>t?
- | ^
- | |
- | expected one of `(`, `)`, `+`, `,`, `::`, or `<`
- | help: missing `,`
-
-error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
- --> $DIR/issue-84148-2.rs:4:16
- |
-LL | fn f(t:for<>t?
- | ^ expected one of `->`, `;`, `where`, or `{`
-
-error: aborting due to 4 previous errors
-
+++ /dev/null
-pub extern
- "invalid-ab_isize" //~ ERROR invalid ABI
-fn foo() {}
-
-fn main() {}
+++ /dev/null
-error[E0703]: invalid ABI: found `invalid-ab_isize`
- --> $DIR/issue-8537.rs:2:3
- |
-LL | "invalid-ab_isize"
- | ^^^^^^^^^^^^^^^^^^ invalid ABI
- |
- = help: valid ABIs: Rust, C, C-unwind, cdecl, stdcall, stdcall-unwind, fastcall, vectorcall, thiscall, thiscall-unwind, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0703`.
+++ /dev/null
-const pub () {}
-//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`
-pub fn main() {}
+++ /dev/null
-error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
- --> $DIR/issue-86895.rs:1:7
- |
-LL | const pub () {}
- | ^^^ expected one of `async`, `extern`, `fn`, or `unsafe`
-
-error: aborting due to previous error
-
+++ /dev/null
-// Tests that a suggestion is issued if the user wrote a colon instead of
-// a path separator in a match arm.
-
-enum Foo {
- Bar,
- Baz,
-}
-
-fn f() -> Foo { Foo::Bar }
-
-fn g1() {
- match f() {
- Foo:Bar => {}
- //~^ ERROR: expected one of
- //~| HELP: maybe write a path separator here
- _ => {}
- }
- match f() {
- Foo::Bar:Baz => {}
- //~^ ERROR: expected one of
- //~| HELP: maybe write a path separator here
- _ => {}
- }
- match f() {
- Foo:Bar::Baz => {}
- //~^ ERROR: expected one of
- //~| HELP: maybe write a path separator here
- _ => {}
- }
- match f() {
- Foo: Bar::Baz if true => {}
- //~^ ERROR: expected one of
- //~| HELP: maybe write a path separator here
- _ => {}
- }
- if let Bar:Baz = f() {
- //~^ ERROR: expected one of
- //~| HELP: maybe write a path separator here
- }
-}
-
-fn g1_neg() {
- match f() {
- ref Foo: Bar::Baz => {}
- //~^ ERROR: expected one of
- _ => {}
- }
-}
-
-fn g2_neg() {
- match f() {
- mut Foo: Bar::Baz => {}
- //~^ ERROR: expected one of
- _ => {}
- }
-}
-
-fn main() {
- let myfoo = Foo::Bar;
- match myfoo {
- Foo::Bar => {}
- Foo:Bar::Baz => {}
- //~^ ERROR: expected one of
- //~| HELP: maybe write a path separator here
- }
-}
+++ /dev/null
-error: expected one of `@` or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:13:12
- |
-LL | Foo:Bar => {}
- | ^
- | |
- | expected one of `@` or `|`
- | help: maybe write a path separator here: `::`
-
-error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `{`, or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:19:17
- |
-LL | Foo::Bar:Baz => {}
- | ^
- | |
- | expected one of 8 possible tokens
- | help: maybe write a path separator here: `::`
-
-error: expected one of `@` or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:25:12
- |
-LL | Foo:Bar::Baz => {}
- | ^
- | |
- | expected one of `@` or `|`
- | help: maybe write a path separator here: `::`
-
-error: expected one of `@` or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:31:12
- |
-LL | Foo: Bar::Baz if true => {}
- | ^
- | |
- | expected one of `@` or `|`
- | help: maybe write a path separator here: `::`
-
-error: expected one of `@` or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:36:15
- |
-LL | if let Bar:Baz = f() {
- | ^
- | |
- | expected one of `@` or `|`
- | help: maybe write a path separator here: `::`
-
-error: expected one of `=>`, `@`, `if`, or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:44:16
- |
-LL | ref Foo: Bar::Baz => {}
- | ^ expected one of `=>`, `@`, `if`, or `|`
-
-error: expected one of `=>`, `@`, `if`, or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:52:16
- |
-LL | mut Foo: Bar::Baz => {}
- | ^ expected one of `=>`, `@`, `if`, or `|`
-
-error: expected one of `@` or `|`, found `:`
- --> $DIR/issue-87086-colon-path-sep.rs:62:12
- |
-LL | Foo:Bar::Baz => {}
- | ^
- | |
- | expected one of `@` or `|`
- | help: maybe write a path separator here: `::`
-
-error: aborting due to 8 previous errors
-
+++ /dev/null
-// run-rustfix
-// Parser should know when a semicolon is missing.
-// https://github.com/rust-lang/rust/issues/87197
-
-fn main() {
- let x = 100; //~ ERROR: expected `;`
- println!("{}", x); //~ ERROR: expected `;`
- let y = 200; //~ ERROR: expected `;`
- println!("{}", y);
-}
+++ /dev/null
-// run-rustfix
-// Parser should know when a semicolon is missing.
-// https://github.com/rust-lang/rust/issues/87197
-
-fn main() {
- let x = 100 //~ ERROR: expected `;`
- println!("{}", x) //~ ERROR: expected `;`
- let y = 200 //~ ERROR: expected `;`
- println!("{}", y);
-}
+++ /dev/null
-error: expected `;`, found `println`
- --> $DIR/issue-87197-missing-semicolon.rs:6:16
- |
-LL | let x = 100
- | ^ help: add `;` here
-LL | println!("{}", x)
- | ------- unexpected token
-
-error: expected `;`, found keyword `let`
- --> $DIR/issue-87197-missing-semicolon.rs:7:22
- |
-LL | println!("{}", x)
- | ^ help: add `;` here
-LL | let y = 200
- | --- unexpected token
-
-error: expected `;`, found `println`
- --> $DIR/issue-87197-missing-semicolon.rs:8:16
- |
-LL | let y = 200
- | ^ help: add `;` here
-LL | println!("{}", y);
- | ------- unexpected token
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// edition:2018
-
-// Test that even when `const` is already present, the proposed fix is `const const async`,
-// like for `pub pub`.
-
-const async const fn test() {}
-//~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `const`
-//~| NOTE expected one of `extern`, `fn`, or `unsafe`
-//~| HELP `const` must come before `async`
-//~| SUGGESTION const async
-//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+++ /dev/null
-error: expected one of `extern`, `fn`, or `unsafe`, found keyword `const`
- --> $DIR/const-async-const.rs:6:13
- |
-LL | const async const fn test() {}
- | ------^^^^^
- | | |
- | | expected one of `extern`, `fn`, or `unsafe`
- | help: `const` must come before `async`: `const async`
- |
- = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-// There is an order to respect for keywords before a function:
-// `<visibility>, const, async, unsafe, extern, "<ABI>"`
-//
-// This test ensures the compiler is helpful about them being misplaced.
-// Visibilities are tested elsewhere.
-
-async unsafe const fn test() {}
-//~^ ERROR expected one of `extern` or `fn`, found keyword `const`
-//~| NOTE expected one of `extern` or `fn`
-//~| HELP `const` must come before `async unsafe`
-//~| SUGGESTION const async unsafe
-//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+++ /dev/null
-error: expected one of `extern` or `fn`, found keyword `const`
- --> $DIR/several-kw-jump.rs:9:14
- |
-LL | async unsafe const fn test() {}
- | -------------^^^^^
- | | |
- | | expected one of `extern` or `fn`
- | help: `const` must come before `async unsafe`: `const async unsafe`
- |
- = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-// There is an order to respect for keywords before a function:
-// `<visibility>, const, async, unsafe, extern, "<ABI>"`
-//
-// This test ensures the compiler is helpful about them being misplaced.
-// Visibilities are tested elsewhere.
-
-unsafe async fn test() {}
-//~^ ERROR expected one of `extern` or `fn`, found keyword `async`
-//~| NOTE expected one of `extern` or `fn`
-//~| HELP `async` must come before `unsafe`
-//~| SUGGESTION async unsafe
-//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+++ /dev/null
-error: expected one of `extern` or `fn`, found keyword `async`
- --> $DIR/wrong-async.rs:9:8
- |
-LL | unsafe async fn test() {}
- | -------^^^^^
- | | |
- | | expected one of `extern` or `fn`
- | help: `async` must come before `unsafe`: `async unsafe`
- |
- = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-// There is an order to respect for keywords before a function:
-// `<visibility>, const, async, unsafe, extern, "<ABI>"`
-//
-// This test ensures the compiler is helpful about them being misplaced.
-// Visibilities are tested elsewhere.
-
-unsafe const fn test() {}
-//~^ ERROR expected one of `extern` or `fn`, found keyword `const`
-//~| NOTE expected one of `extern` or `fn`
-//~| HELP `const` must come before `unsafe`
-//~| SUGGESTION const unsafe
-//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+++ /dev/null
-error: expected one of `extern` or `fn`, found keyword `const`
- --> $DIR/wrong-const.rs:9:8
- |
-LL | unsafe const fn test() {}
- | -------^^^^^
- | | |
- | | expected one of `extern` or `fn`
- | help: `const` must come before `unsafe`: `const unsafe`
- |
- = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
-
-error: aborting due to previous error
-
+++ /dev/null
-// edition:2018
-
-// There is an order to respect for keywords before a function:
-// `<visibility>, const, async, unsafe, extern, "<ABI>"`
-//
-// This test ensures the compiler is helpful about them being misplaced.
-// Visibilities are tested elsewhere.
-
-extern unsafe fn test() {}
-//~^ ERROR expected `fn`, found keyword `unsafe`
-//~| NOTE expected `fn`
-//~| HELP `unsafe` must come before `extern`
-//~| SUGGESTION unsafe extern
-//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+++ /dev/null
-error: expected `fn`, found keyword `unsafe`
- --> $DIR/wrong-unsafe.rs:9:8
- |
-LL | extern unsafe fn test() {}
- | -------^^^^^^
- | | |
- | | expected `fn`
- | help: `unsafe` must come before `extern`: `unsafe extern`
- |
- = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
-
-error: aborting due to previous error
-
+++ /dev/null
-struct Foo {}
-
-impl Foo {
- pub fn bar()
- //~^ ERROR: expected `;`, found `}`
- //~| ERROR: associated function in `impl` without body
-}
-
-fn main() {}
+++ /dev/null
-error: expected `;`, found `}`
- --> $DIR/issue-87635.rs:4:17
- |
-LL | pub fn bar()
- | ^ help: add `;` here
-...
-LL | }
- | - unexpected token
-
-error: associated function in `impl` without body
- --> $DIR/issue-87635.rs:4:5
- |
-LL | pub fn bar()
- | ^^^^^^^^^^^-
- | |
- | help: provide a definition for the function: `{ <body> }`
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-macro_rules! foo {
- ( $f:path ) => {{
- let _: usize = $f; //~ERROR
- }};
-}
-
-struct Baz;
-
-fn main() {
- foo!(Baz);
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/issue-87812-path.rs:3:24
- |
-LL | let _: usize = $f;
- | ----- ^^ expected `usize`, found struct `Baz`
- | |
- | expected due to this
-...
-LL | foo!(Baz);
- | --------- in this macro invocation
- |
- = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-#![deny(break_with_label_and_loop)]
-
-macro_rules! foo {
- ( $f:block ) => {
- '_l: loop {
- break '_l $f; //~ERROR
- }
- };
-}
-
-fn main() {
- let x = foo!({ 3 });
-}
+++ /dev/null
-error: this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression
- --> $DIR/issue-87812.rs:6:13
- |
-LL | break '_l $f;
- | ^^^^^^^^^^^^
-...
-LL | let x = foo!({ 3 });
- | ----------- in this macro invocation
- |
-note: the lint level is defined here
- --> $DIR/issue-87812.rs:1:9
- |
-LL | #![deny(break_with_label_and_loop)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
-help: wrap this expression in parentheses
- |
-LL | break '_l ($f);
- | + +
-
-error: aborting due to previous error
-
+++ /dev/null
-// run-rustfix
-#[allow(unused_parens)]
-fn main() {
- let _ = 1; //~ ERROR leading `+` is not supported
- let _ = (1.0 + 2.0) * 3.0; //~ ERROR leading `+` is not supported
- //~| ERROR leading `+` is not supported
- let _ = [3, 4+6]; //~ ERROR leading `+` is not supported
-}
+++ /dev/null
-// run-rustfix
-#[allow(unused_parens)]
-fn main() {
- let _ = +1; //~ ERROR leading `+` is not supported
- let _ = (1.0 + +2.0) * +3.0; //~ ERROR leading `+` is not supported
- //~| ERROR leading `+` is not supported
- let _ = [+3, 4+6]; //~ ERROR leading `+` is not supported
-}
+++ /dev/null
-error: leading `+` is not supported
- --> $DIR/issue-88276-unary-plus.rs:4:13
- |
-LL | let _ = +1;
- | ^ unexpected `+`
- |
-help: try removing the `+`
- |
-LL - let _ = +1;
-LL + let _ = 1;
- |
-
-error: leading `+` is not supported
- --> $DIR/issue-88276-unary-plus.rs:5:20
- |
-LL | let _ = (1.0 + +2.0) * +3.0;
- | ^ unexpected `+`
- |
-help: try removing the `+`
- |
-LL - let _ = (1.0 + +2.0) * +3.0;
-LL + let _ = (1.0 + 2.0) * +3.0;
- |
-
-error: leading `+` is not supported
- --> $DIR/issue-88276-unary-plus.rs:5:28
- |
-LL | let _ = (1.0 + +2.0) * +3.0;
- | ^ unexpected `+`
- |
-help: try removing the `+`
- |
-LL - let _ = (1.0 + +2.0) * +3.0;
-LL + let _ = (1.0 + +2.0) * 3.0;
- |
-
-error: leading `+` is not supported
- --> $DIR/issue-88276-unary-plus.rs:7:14
- |
-LL | let _ = [+3, 4+6];
- | ^ unexpected `+`
- |
-help: try removing the `+`
- |
-LL - let _ = [+3, 4+6];
-LL + let _ = [3, 4+6];
- |
-
-error: aborting due to 4 previous errors
-
+++ /dev/null
-// check-pass
-
-#![allow(non_camel_case_types)]
-
-struct union;
-
-impl union {
- pub fn new() -> Self {
- union { }
- }
-}
-
-fn main() {
- let _u = union::new();
-}
+++ /dev/null
-// Regression test for the ICE described in #88770.
-
-// error-pattern:this file contains an unclosed delimiter
-// error-pattern:expected one of
-// error-pattern:missing `in` in `for` loop
-// error-pattern:expected `;`, found `e`
-
-fn m(){print!("",(c for&g
-u
-e
-e
+++ /dev/null
-error: this file contains an unclosed delimiter
- --> $DIR/issue-88770.rs:11:3
- |
-LL | fn m(){print!("",(c for&g
- | - - - unclosed delimiter
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-...
-LL | e
- | ^
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-88770.rs:11:3
- |
-LL | fn m(){print!("",(c for&g
- | - - - unclosed delimiter
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-...
-LL | e
- | ^
-
-error: this file contains an unclosed delimiter
- --> $DIR/issue-88770.rs:11:3
- |
-LL | fn m(){print!("",(c for&g
- | - - - unclosed delimiter
- | | |
- | | unclosed delimiter
- | unclosed delimiter
-...
-LL | e
- | ^
-
-error: missing `in` in `for` loop
- --> $DIR/issue-88770.rs:8:26
- |
-LL | fn m(){print!("",(c for&g
- | __________________________^
-LL | | u
- | |_ help: try adding `in` here
-
-error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found keyword `for`
- --> $DIR/issue-88770.rs:8:21
- |
-LL | fn m(){print!("",(c for&g
- | ^^^ expected one of 8 possible tokens
-
-error: expected `;`, found `e`
- --> $DIR/issue-88770.rs:10:2
- |
-LL | e
- | ^ help: add `;` here
-LL | e
- | - unexpected token
-
-error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `)`
- --> $DIR/issue-88770.rs:11:3
- |
-LL | e
- | ^ expected one of 7 possible tokens
-
-error: aborting due to 7 previous errors
-
+++ /dev/null
-// Regression test for #88818 (improve error message for missing trait
-// in `impl for X`).
-
-struct S { }
-impl for S { }
-//~^ ERROR: missing trait in a trait impl
-//~| HELP: add a trait here
-//~| HELP: for an inherent impl, drop this `for`
-
-fn main() {}
+++ /dev/null
-error: missing trait in a trait impl
- --> $DIR/issue-88818.rs:5:5
- |
-LL | impl for S { }
- | ^
- |
-help: add a trait here
- |
-LL | impl Trait for S { }
- | +++++
-help: for an inherent impl, drop this `for`
- |
-LL - impl for S { }
-LL + impl S { }
- |
-
-error: aborting due to previous error
-
+++ /dev/null
-// Regression test for #89388.
-
-fn main() {
- let option: Option<&[u8]> = Some(b"...");
- let _ = option.map([_]::to_vec);
- //~^ ERROR: missing angle brackets in associated item path
-}
+++ /dev/null
-error: missing angle brackets in associated item path
- --> $DIR/issue-89388.rs:5:24
- |
-LL | let _ = option.map([_]::to_vec);
- | ^^^^^^^^^^^ help: try: `<[_]>::to_vec`
-
-error: aborting due to previous error
-
+++ /dev/null
-// Regression test for issue #89396: Try to recover from a
-// `=>` -> `=` or `->` typo in a match arm.
-
-// run-rustfix
-
-fn main() {
- let opt = Some(42);
- let _ = match opt {
- Some(_) => true,
- //~^ ERROR: expected one of
- //~| HELP: try using a fat arrow here
- None => false,
- //~^ ERROR: expected one of
- //~| HELP: try using a fat arrow here
- };
-}
+++ /dev/null
-// Regression test for issue #89396: Try to recover from a
-// `=>` -> `=` or `->` typo in a match arm.
-
-// run-rustfix
-
-fn main() {
- let opt = Some(42);
- let _ = match opt {
- Some(_) = true,
- //~^ ERROR: expected one of
- //~| HELP: try using a fat arrow here
- None -> false,
- //~^ ERROR: expected one of
- //~| HELP: try using a fat arrow here
- };
-}
+++ /dev/null
-error: expected one of `=>`, `if`, or `|`, found `=`
- --> $DIR/issue-89396.rs:9:17
- |
-LL | Some(_) = true,
- | ^
- | |
- | expected one of `=>`, `if`, or `|`
- | help: try using a fat arrow here: `=>`
-
-error: expected one of `=>`, `@`, `if`, or `|`, found `->`
- --> $DIR/issue-89396.rs:12:14
- |
-LL | None -> false,
- | ^^
- | |
- | expected one of `=>`, `@`, `if`, or `|`
- | help: try using a fat arrow here: `=>`
-
-error: aborting due to 2 previous errors
-
+++ /dev/null
-fn main() {
- const EMPTY_ARRAY = [];
- //~^ missing type for `const` item
-}
+++ /dev/null
-error: missing type for `const` item
- --> $DIR/issue-89574.rs:2:11
- |
-LL | const EMPTY_ARRAY = [];
- | ^^^^^^^^^^^ help: provide a type for the item: `EMPTY_ARRAY: <type>`
-
-error: aborting due to previous error
-
+++ /dev/null
-// aux-build:issue-89971-outer-attr-following-inner-attr-ice.rs
-
-#[macro_use]
-extern crate issue_89971_outer_attr_following_inner_attr_ice;
-
-fn main() {
- Mew();
- X {};
-}
-
-#![deny(missing_docs)]
-//~^ ERROR an inner attribute is not permitted in this context
-#[derive(ICE)]
-#[deny(missing_docs)]
-struct Mew();
+++ /dev/null
-error: an inner attribute is not permitted in this context
- --> $DIR/issue-89971-outer-attr-following-inner-attr-ice.rs:11:1
- |
-LL | #![deny(missing_docs)]
- | ^^^^^^^^^^^^^^^^^^^^^^
-...
-LL | struct Mew();
- | ------------- the inner attribute doesn't annotate this struct
- |
- = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
-help: to annotate the struct, change the attribute from inner to outer style
- |
-LL - #![deny(missing_docs)]
-LL + #[deny(missing_docs)]
- |
-
-error: aborting due to previous error
-
--- /dev/null
+fn main() {
+ a.5.2E+
+ //~^ ERROR: unexpected token: `5.2E+`
+ //~| ERROR: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+`
+ //~| ERROR: expected at least one digit in exponent
+}
--- /dev/null
+error: expected at least one digit in exponent
+ --> $DIR/issue-90728.rs:2:7
+ |
+LL | a.5.2E+
+ | ^^^^^
+
+error: unexpected token: `5.2E+`
+ --> $DIR/issue-90728.rs:2:7
+ |
+LL | a.5.2E+
+ | ^^^^^
+
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found `5.2E+`
+ --> $DIR/issue-90728.rs:2:7
+ |
+LL | a.5.2E+
+ | ^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// include file for issue-21146.rs
+
+parse_error
--- /dev/null
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(ICE)]
+pub fn derive(_: TokenStream) -> TokenStream {
+ r#"#[allow(missing_docs)] struct X { }"#.parse().unwrap()
+}
--- /dev/null
+// run-rustfix
+
+pub struct A { pub foo: isize }
+
+fn a() -> A { panic!() }
+
+fn main() {
+ let A { .. } = a(); //~ ERROR: expected `}`
+}
--- /dev/null
+// run-rustfix
+
+pub struct A { pub foo: isize }
+
+fn a() -> A { panic!() }
+
+fn main() {
+ let A { .., } = a(); //~ ERROR: expected `}`
+}
--- /dev/null
+error: expected `}`, found `,`
+ --> $DIR/issue-10392-2.rs:8:15
+ |
+LL | let A { .., } = a();
+ | --^
+ | | |
+ | | expected `}`
+ | | help: remove this comma
+ | `..` must be at the end and cannot have a trailing comma
+
+error: aborting due to previous error
+
--- /dev/null
+struct A { foo: isize }
+
+fn a() -> A { panic!() }
+
+fn main() {
+ let A { , } = a(); //~ ERROR expected ident
+}
--- /dev/null
+error: expected identifier, found `,`
+ --> $DIR/issue-10392.rs:6:13
+ |
+LL | let A { , } = a();
+ | - ^ expected identifier
+ | |
+ | while parsing the fields for this pattern
+
+error: aborting due to previous error
+
--- /dev/null
+struct Obj {
+ //~^ NOTE: unclosed delimiter
+ member: usize
+)
+//~^ ERROR mismatched closing delimiter
+//~| NOTE mismatched closing delimiter
+
+fn main() {}
--- /dev/null
+error: mismatched closing delimiter: `)`
+ --> $DIR/issue-10636-1.rs:1:12
+ |
+LL | struct Obj {
+ | ^ unclosed delimiter
+...
+LL | )
+ | ^ mismatched closing delimiter
+
+error: aborting due to previous error
+
--- /dev/null
+// FIXME(31528) we emit a bunch of silly errors here due to continuing past the
+// first one. This would be easy-ish to address by better recovery in tokenisation.
+
+pub fn trace_option(option: Option<isize>) {
+ option.map(|some| 42;
+ //~^ ERROR: expected one of
+
+}
+//~^ ERROR: expected expression, found `)`
+
+fn main() {}
--- /dev/null
+error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
+ --> $DIR/issue-10636-2.rs:5:15
+ |
+LL | option.map(|some| 42;
+ | ^ ^ help: `)` may belong here
+ | |
+ | unclosed delimiter
+
+error: expected expression, found `)`
+ --> $DIR/issue-10636-2.rs:8:1
+ |
+LL | }
+ | ^ expected expression
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+fn main() {
+ if true {
+ } else if { //~ ERROR missing condition
+ //~^ ERROR mismatched types
+ } else {
+ }
+}
+
+fn foo() {
+ if true {
+ } else if { //~ ERROR missing condition
+ //~^ ERROR mismatched types
+ }
+ bar();
+}
+
+fn bar() {}
--- /dev/null
+error: missing condition for `if` expression
+ --> $DIR/issue-13483.rs:3:14
+ |
+LL | } else if {
+ | ^ expected if condition here
+
+error: missing condition for `if` expression
+ --> $DIR/issue-13483.rs:11:14
+ |
+LL | } else if {
+ | ^ expected if condition here
+
+error[E0308]: mismatched types
+ --> $DIR/issue-13483.rs:3:15
+ |
+LL | } else if {
+ | _______________^
+LL | |
+LL | | } else {
+ | |_____^ expected `bool`, found `()`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-13483.rs:11:15
+ |
+LL | } else if {
+ | _______________^
+LL | |
+LL | | }
+ | |_____^ expected `bool`, found `()`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+enum X<'a, T, 'b> {
+//~^ ERROR lifetime parameters must be declared prior to type parameters
+ A(&'a &'b T)
+}
+
+fn main() {}
--- /dev/null
+error: lifetime parameters must be declared prior to type parameters
+ --> $DIR/issue-14303-enum.rs:1:15
+ |
+LL | enum X<'a, T, 'b> {
+ | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
+
+error: aborting due to previous error
+
--- /dev/null
+fn foo<'a, T, 'b>(x: &'a T) {}
+//~^ ERROR lifetime parameters must be declared prior to type parameters
+
+fn main() {}
--- /dev/null
+error: lifetime parameters must be declared prior to type parameters
+ --> $DIR/issue-14303-fn-def.rs:1:15
+ |
+LL | fn foo<'a, T, 'b>(x: &'a T) {}
+ | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
+
+error: aborting due to previous error
+
--- /dev/null
+error[E0747]: type provided when a lifetime was expected
+ --> $DIR/issue-14303-fncall.rs:16:26
+ |
+LL | .collect::<Vec<S<_, 'a>>>();
+ | ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0747`.
--- /dev/null
+error[E0747]: inferred provided when a lifetime was expected
+ --> $DIR/issue-14303-fncall.rs:16:26
+ |
+LL | .collect::<Vec<S<_, 'a>>>();
+ | ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0747`.
--- /dev/null
+// revisions: full generic_arg
+// compile-flags: -Zborrowck=mir
+// can't run rustfix because it doesn't handle multipart suggestions correctly
+// we need the above to avoid ast borrowck failure in recovered code
+#![cfg_attr(generic_arg, feature(generic_arg_infer))]
+
+
+struct S<'a, T> {
+ a: &'a T,
+ b: &'a T,
+}
+
+fn foo<'a, 'b>(start: &'a usize, end: &'a usize) {
+ let _x = (*start..*end)
+ .map(|x| S { a: start, b: end })
+ .collect::<Vec<S<_, 'a>>>();
+ //[generic_arg]~^ ERROR inferred provided when a lifetime was expected
+ //[full]~^^ ERROR type provided when a lifetime was expected
+}
+
+fn main() {}
--- /dev/null
+struct X<T>(T);
+
+impl<'a, T, 'b> X<T> {}
+//~^ ERROR lifetime parameters must be declared prior to type parameters
+
+fn main() {}
--- /dev/null
+error: lifetime parameters must be declared prior to type parameters
+ --> $DIR/issue-14303-impl.rs:3:13
+ |
+LL | impl<'a, T, 'b> X<T> {}
+ | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
+
+error: aborting due to previous error
+
--- /dev/null
+mod foo {
+ pub struct X<'a, 'b, 'c, T> {
+ a: &'a str,
+ b: &'b str,
+ c: &'c str,
+ t: T,
+ }
+}
+
+fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
+//~^ ERROR type provided when a lifetime was expected
+
+fn main() {}
--- /dev/null
+error[E0747]: type provided when a lifetime was expected
+ --> $DIR/issue-14303-path.rs:10:37
+ |
+LL | fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
+ | ^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0747`.
--- /dev/null
+struct X<'a, T, 'b> {
+//~^ ERROR lifetime parameters must be declared prior to type parameters
+ x: &'a &'b T
+}
+
+fn main() {}
--- /dev/null
+error: lifetime parameters must be declared prior to type parameters
+ --> $DIR/issue-14303-struct.rs:1:17
+ |
+LL | struct X<'a, T, 'b> {
+ | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
+
+error: aborting due to previous error
+
--- /dev/null
+trait Foo<'a, T, 'b> {}
+//~^ ERROR lifetime parameters must be declared prior to type parameters
+
+fn main() {}
--- /dev/null
+error: lifetime parameters must be declared prior to type parameters
+ --> $DIR/issue-14303-trait.rs:1:18
+ |
+LL | trait Foo<'a, T, 'b> {}
+ | --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {
+ let ref
+ (); //~ ERROR expected identifier, found `(`
+}
--- /dev/null
+error: expected identifier, found `(`
+ --> $DIR/issue-15914.rs:3:9
+ |
+LL | ();
+ | ^ expected identifier
+
+error: aborting due to previous error
+
--- /dev/null
+use std::io;
+
+fn main(){
+ let x: io::Result<()> = Ok(());
+ match x {
+ Err(ref e) if e.kind == io::EndOfFile {
+ //~^ NOTE while parsing this struct
+ return
+ //~^ ERROR expected identifier, found keyword `return`
+ //~| NOTE expected identifier, found keyword
+ }
+ //~^ NOTE expected one of `.`, `=>`, `?`, or an operator
+ _ => {}
+ //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
+ //~| NOTE unexpected token
+ }
+}
--- /dev/null
+error: expected identifier, found keyword `return`
+ --> $DIR/issue-15980.rs:8:13
+ |
+LL | Err(ref e) if e.kind == io::EndOfFile {
+ | ------------- while parsing this struct
+LL |
+LL | return
+ | ^^^^^^ expected identifier, found keyword
+ |
+help: you can escape reserved keywords to use them as identifiers
+ |
+LL | r#return
+ |
+
+error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
+ --> $DIR/issue-15980.rs:13:9
+ |
+LL | }
+ | - expected one of `.`, `=>`, `?`, or an operator
+LL |
+LL | _ => {}
+ | ^ unexpected token
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+mod blade_runner {
+ #vec[doc( //~ ERROR expected one of `!` or `[`, found `vec`
+ brief = "Blade Runner is probably the best movie ever",
+ desc = "I like that in the world of Blade Runner it is always
+ raining, and that it's always night time. And Aliens
+ was also a really good movie.
+
+ Alien 3 was crap though."
+ )]
+}
--- /dev/null
+error: expected one of `!` or `[`, found `vec`
+ --> $DIR/issue-1655.rs:2:6
+ |
+LL | #vec[doc(
+ | ^^^ expected one of `!` or `[`
+
+error: aborting due to previous error
+
--- /dev/null
+enum X {
+ A = 3,
+ //~^ ERROR custom discriminant values are not allowed in enums with tuple or struct variants
+ B(usize)
+}
+
+fn main() {}
--- /dev/null
+error[E0658]: custom discriminant values are not allowed in enums with tuple or struct variants
+ --> $DIR/issue-17383.rs:2:9
+ |
+LL | A = 3,
+ | ^ disallowed custom discriminant
+LL |
+LL | B(usize)
+ | -------- tuple variant defined here
+ |
+ = note: see issue #60553 <https://github.com/rust-lang/rust/issues/60553> for more information
+ = help: add `#![feature(arbitrary_enum_discriminant)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
--- /dev/null
+const
+mut //~ ERROR: const globals cannot be mutable
+//~^^ HELP you might want to declare a static instead
+FOO: usize = 3;
+
+fn main() {
+}
--- /dev/null
+error: const globals cannot be mutable
+ --> $DIR/issue-17718-const-mut.rs:2:1
+ |
+LL | const
+ | ----- help: you might want to declare a static instead: `static`
+LL | mut
+ | ^^^ cannot be mutable
+
+error: aborting due to previous error
+
--- /dev/null
+struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found keyword `where`
+
+fn main() {}
--- /dev/null
+error: expected item, found keyword `where`
+ --> $DIR/issue-17904-2.rs:1:24
+ |
+LL | struct Bar<T> { x: T } where T: Copy
+ | ^^^^^ expected item
+
+error: aborting due to previous error
+
--- /dev/null
+struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax.
+struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well.
+struct Baz<U>(U) where U: Eq; // This rightfully signals no error as well.
+struct Foo<T> where T: Copy, (T); //~ ERROR expected one of `:`, `==`, or `=`, found `;`
+
+fn main() {}
--- /dev/null
+error: expected one of `:`, `==`, or `=`, found `;`
+ --> $DIR/issue-17904.rs:4:33
+ |
+LL | struct Foo<T> where T: Copy, (T);
+ | ^ expected one of `:`, `==`, or `=`
+
+error: aborting due to previous error
+
--- /dev/null
+fn log(a: i32, b: i32) {}
+
+fn main() {
+ let error = 42;
+ log(error, 0b);
+ //~^ ERROR no valid digits found for number
+}
--- /dev/null
+error[E0768]: no valid digits found for number
+ --> $DIR/issue-1802-1.rs:5:16
+ |
+LL | log(error, 0b);
+ | ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0768`.
--- /dev/null
+fn log(a: i32, b: i32) {}
+
+fn main() {
+ let error = 42;
+ log(error, 0b);
+ //~^ ERROR no valid digits found for number
+}
--- /dev/null
+error[E0768]: no valid digits found for number
+ --> $DIR/issue-1802-2.rs:5:16
+ |
+LL | log(error, 0b);
+ | ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0768`.
--- /dev/null
+fn main() { // we don't complain about the return type being `{integer}`
+ let t = (42, 42);
+ t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
+}
+
+fn foo() -> usize { // we don't complain about the return type being unit
+ let t = (42, 42);
+ t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
+ 42;
+}
--- /dev/null
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
+ --> $DIR/issue-19096.rs:3:8
+ |
+LL | t.0::<isize>;
+ | ^^ expected one of `.`, `;`, `?`, `}`, or an operator
+
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::`
+ --> $DIR/issue-19096.rs:8:8
+ |
+LL | t.0::<isize>;
+ | ^^ expected one of `.`, `;`, `?`, `}`, or an operator
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+trait T {
+ extern "Rust" unsafe fn foo();
+ //~^ ERROR expected `{`, found keyword `unsafe`
+}
+
+fn main() {}
--- /dev/null
+error: expected `{`, found keyword `unsafe`
+ --> $DIR/issue-19398.rs:2:19
+ |
+LL | trait T {
+ | - while parsing this item list starting here
+LL | extern "Rust" unsafe fn foo();
+ | ^^^^^^ expected `{`
+LL |
+LL | }
+ | - the item list ends here
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+
+
+type Type_1_<'a, T> = &'a T;
+
+
+type Type_1<'a T> = &'a T; //~ error: expected one of `,`, `:`, or `>`, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
--- /dev/null
+error: expected one of `,`, `:`, or `>`, found `T`
+ --> $DIR/issue-20616-1.rs:9:16
+ |
+LL | type Type_1<'a T> = &'a T;
+ | ^ expected one of `,`, `:`, or `>`
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,`, `:`, `=`, or `>`, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
--- /dev/null
+error: expected one of `,`, `:`, `=`, or `>`, found `(`
+ --> $DIR/issue-20616-2.rs:12:31
+ |
+LL | type Type_2 = Type_1_<'static ()>;
+ | ^ expected one of `,`, `:`, `=`, or `>`
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+type Type_3<T> = Box<T,,>;
+//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
--- /dev/null
+error: expected one of `>`, a const expression, lifetime, or type, found `,`
+ --> $DIR/issue-20616-3.rs:13:24
+ |
+LL | type Type_3<T> = Box<T,,>;
+ | ^ expected one of `>`, a const expression, lifetime, or type
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+type Type_4<T> = Type_1_<'static,, T>;
+//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
--- /dev/null
+error: expected one of `>`, a const expression, lifetime, or type, found `,`
+ --> $DIR/issue-20616-4.rs:16:34
+ |
+LL | type Type_4<T> = Type_1_<'static,, T>;
+ | ^ expected one of `>`, a const expression, lifetime, or type
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+type Type_5<'a> = Type_1_<'a, (),,>;
+//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
--- /dev/null
+error: expected one of `>`, a const expression, lifetime, or type, found `,`
+ --> $DIR/issue-20616-5.rs:22:34
+ |
+LL | type Type_5<'a> = Type_1_<'a, (),,>;
+ | ^ expected one of `>`, a const expression, lifetime, or type
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+type Type_6 = Type_5_<'a,,>;
+//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
--- /dev/null
+error: expected one of `>`, a const expression, lifetime, or type, found `,`
+ --> $DIR/issue-20616-6.rs:25:26
+ |
+LL | type Type_6 = Type_5_<'a,,>;
+ | ^ expected one of `>`, a const expression, lifetime, or type
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+type Type_7 = Box<(),,>;
+//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected ident, found `,`
--- /dev/null
+error: expected one of `>`, a const expression, lifetime, or type, found `,`
+ --> $DIR/issue-20616-7.rs:28:22
+ |
+LL | type Type_7 = Box<(),,>;
+ | ^ expected one of `>`, a const expression, lifetime, or type
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+type Type_8<'a,,> = &'a ();
+//~^ error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
+
+
+//type Type_9<T,,> = Box<T>; // error: expected identifier, found `,`
--- /dev/null
+error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
+ --> $DIR/issue-20616-8.rs:31:16
+ |
+LL | type Type_8<'a,,> = &'a ();
+ | ^ expected one of `#`, `>`, `const`, identifier, or lifetime
+
+error: aborting due to previous error
+
--- /dev/null
+// We need all these 9 issue-20616-N.rs files
+// because we can only catch one parsing error at a time
+
+type Type_1_<'a, T> = &'a T;
+
+
+//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
+
+
+//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
+
+
+//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
+
+
+//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
+
+
+type Type_5_<'a> = Type_1_<'a, ()>;
+
+
+//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
+
+
+//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
+
+
+//type Type_7 = Box<(),,>; // error: expected type, found `,`
+
+
+//type Type_8<'a,,> = &'a (); // error: expected identifier, found `,`
+
+
+type Type_9<T,,> = Box<T>;
+//~^ error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
--- /dev/null
+error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,`
+ --> $DIR/issue-20616-9.rs:34:15
+ |
+LL | type Type_9<T,,> = Box<T>;
+ | ^ expected one of `#`, `>`, `const`, identifier, or lifetime
+
+error: aborting due to previous error
+
--- /dev/null
+struct Foo;
+
+impl Foo {
+ fn foo() {}
+
+ #[stable(feature = "rust1", since = "1.0.0")]
+ //~^ ERROR expected item after attributes
+}
+
+fn main() {}
--- /dev/null
+error: expected item after attributes
+ --> $DIR/issue-20711-2.rs:6:5
+ |
+LL | impl Foo {
+ | - while parsing this item list starting here
+...
+LL | #[stable(feature = "rust1", since = "1.0.0")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | }
+ | - the item list ends here
+
+error: aborting due to previous error
+
--- /dev/null
+struct Foo;
+
+impl Foo {
+ #[stable(feature = "rust1", since = "1.0.0")]
+ //~^ ERROR expected item after attributes
+}
+
+fn main() {}
--- /dev/null
+error: expected item after attributes
+ --> $DIR/issue-20711.rs:4:5
+ |
+LL | impl Foo {
+ | - while parsing this item list starting here
+LL | #[stable(feature = "rust1", since = "1.0.0")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | }
+ | - the item list ends here
+
+error: aborting due to previous error
+
--- /dev/null
+// error-pattern: expected one of `!` or `::`, found `<eof>`
+include!("auxiliary/issue-21146-inc.rs");
+fn main() {}
--- /dev/null
+error: expected one of `!` or `::`, found `<eof>`
+ --> $DIR/auxiliary/issue-21146-inc.rs:3:1
+ |
+LL | parse_error
+ | ^^^^^^^^^^^ expected one of `!` or `::`
+
+error: aborting due to previous error
+
--- /dev/null
+trait MyTrait<T>: Iterator {
+ Item = T;
+ //~^ ERROR expected one of `!` or `::`, found `=`
+}
+
+fn main() {}
--- /dev/null
+error: expected one of `!` or `::`, found `=`
+ --> $DIR/issue-21153.rs:2:10
+ |
+LL | trait MyTrait<T>: Iterator {
+ | - while parsing this item list starting here
+LL | Item = T;
+ | ^ expected one of `!` or `::`
+LL |
+LL | }
+ | - the item list ends here
+
+error: aborting due to previous error
+
--- /dev/null
+// run-pass
+#![allow(unused_imports, overlapping_range_endpoints)]
+// pretty-expanded FIXME #23616
+
+use m::{START, END};
+
+fn main() {
+ match 42 {
+ m::START..=m::END => {},
+ 0..=m::END => {},
+ m::START..=59 => {},
+ _ => {},
+ }
+}
+
+mod m {
+ pub const START: u32 = 4;
+ pub const END: u32 = 14;
+}
--- /dev/null
+fn main() {
+ let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+ where F: Fn() -> i32
+ {
+ let x = f();
+ println!("Y {}",x);
+ return x;
+ };
+
+ caller(bar_handler);
+}
+
+fn bar_handler() -> i32 {
+ 5
+}
--- /dev/null
+error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+ --> $DIR/issue-22647.rs:2:15
+ |
+LL | let caller<F> = |f: F|
+ | ^ expected one of `:`, `;`, `=`, `@`, or `|`
+
+error: aborting due to previous error
+
--- /dev/null
+struct Foo<B> {
+ buffer: B
+}
+
+fn bar() {
+ let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+}
+
+fn main() {}
--- /dev/null
+error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+ --> $DIR/issue-22712.rs:6:12
+ |
+LL | let Foo<Vec<u8>>
+ | ^ expected one of `:`, `;`, `=`, `@`, or `|`
+
+error: aborting due to previous error
+
--- /dev/null
+static foo: isize = 2; } //~ ERROR unexpected closing delimiter:
--- /dev/null
+error: unexpected closing delimiter: `}`
+ --> $DIR/issue-2354-1.rs:1:24
+ |
+LL | static foo: isize = 2; }
+ | ^ unexpected closing delimiter
+
+error: aborting due to previous error
+
--- /dev/null
+fn foo() { //~ NOTE unclosed delimiter
+ match Some(10) {
+ //~^ NOTE this delimiter might not be properly closed...
+ Some(y) => { panic!(); }
+ None => { panic!(); }
+}
+//~^ NOTE ...as it matches this but it has different indentation
+
+fn bar() {
+ let mut i = 0;
+ while (i < 1000) {}
+}
+
+fn main() {}
+//~ ERROR this file contains an unclosed delimiter
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-2354.rs:15:52
+ |
+LL | fn foo() {
+ | - unclosed delimiter
+LL | match Some(10) {
+ | - this delimiter might not be properly closed...
+...
+LL | }
+ | - ...as it matches this but it has different indentation
+...
+LL |
+ | ^
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {
+ let _ = b"\u{a66e}";
+ //~^ ERROR unicode escape in byte string
+
+ let _ = b'\u{a66e}';
+ //~^ ERROR unicode escape in byte string
+
+ let _ = b'\u';
+ //~^ ERROR incorrect unicode escape sequence
+
+ let _ = b'\x5';
+ //~^ ERROR numeric character escape is too short
+
+ let _ = b'\xxy';
+ //~^ ERROR invalid character in numeric character escape: `x`
+
+ let _ = '\x5';
+ //~^ ERROR numeric character escape is too short
+
+ let _ = '\xxy';
+ //~^ ERROR invalid character in numeric character escape: `x`
+
+ let _ = b"\u{a4a4} \xf \u";
+ //~^ ERROR unicode escape in byte string
+ //~^^ ERROR invalid character in numeric character escape: ` `
+ //~^^^ ERROR incorrect unicode escape sequence
+
+ let _ = "\xf \u";
+ //~^ ERROR invalid character in numeric character escape: ` `
+ //~^^ ERROR incorrect unicode escape sequence
+
+ let _ = "\u8f";
+ //~^ ERROR incorrect unicode escape sequence
+}
--- /dev/null
+error: unicode escape in byte string
+ --> $DIR/issue-23620-invalid-escapes.rs:2:15
+ |
+LL | let _ = b"\u{a66e}";
+ | ^^^^^^^^ unicode escape in byte string
+ |
+ = help: unicode escape sequences cannot be used as a byte or in a byte string
+
+error: unicode escape in byte string
+ --> $DIR/issue-23620-invalid-escapes.rs:5:15
+ |
+LL | let _ = b'\u{a66e}';
+ | ^^^^^^^^ unicode escape in byte string
+ |
+ = help: unicode escape sequences cannot be used as a byte or in a byte string
+
+error: incorrect unicode escape sequence
+ --> $DIR/issue-23620-invalid-escapes.rs:8:15
+ |
+LL | let _ = b'\u';
+ | ^^ incorrect unicode escape sequence
+ |
+ = help: format of unicode escape sequences is `\u{...}`
+
+error: numeric character escape is too short
+ --> $DIR/issue-23620-invalid-escapes.rs:11:15
+ |
+LL | let _ = b'\x5';
+ | ^^^
+
+error: invalid character in numeric character escape: `x`
+ --> $DIR/issue-23620-invalid-escapes.rs:14:17
+ |
+LL | let _ = b'\xxy';
+ | ^ invalid character in numeric character escape
+
+error: numeric character escape is too short
+ --> $DIR/issue-23620-invalid-escapes.rs:17:14
+ |
+LL | let _ = '\x5';
+ | ^^^
+
+error: invalid character in numeric character escape: `x`
+ --> $DIR/issue-23620-invalid-escapes.rs:20:16
+ |
+LL | let _ = '\xxy';
+ | ^ invalid character in numeric character escape
+
+error: unicode escape in byte string
+ --> $DIR/issue-23620-invalid-escapes.rs:23:15
+ |
+LL | let _ = b"\u{a4a4} \xf \u";
+ | ^^^^^^^^ unicode escape in byte string
+ |
+ = help: unicode escape sequences cannot be used as a byte or in a byte string
+
+error: invalid character in numeric character escape: ` `
+ --> $DIR/issue-23620-invalid-escapes.rs:23:27
+ |
+LL | let _ = b"\u{a4a4} \xf \u";
+ | ^ invalid character in numeric character escape
+
+error: incorrect unicode escape sequence
+ --> $DIR/issue-23620-invalid-escapes.rs:23:28
+ |
+LL | let _ = b"\u{a4a4} \xf \u";
+ | ^^ incorrect unicode escape sequence
+ |
+ = help: format of unicode escape sequences is `\u{...}`
+
+error: invalid character in numeric character escape: ` `
+ --> $DIR/issue-23620-invalid-escapes.rs:28:17
+ |
+LL | let _ = "\xf \u";
+ | ^ invalid character in numeric character escape
+
+error: incorrect unicode escape sequence
+ --> $DIR/issue-23620-invalid-escapes.rs:28:18
+ |
+LL | let _ = "\xf \u";
+ | ^^ incorrect unicode escape sequence
+ |
+ = help: format of unicode escape sequences is `\u{...}`
+
+error: incorrect unicode escape sequence
+ --> $DIR/issue-23620-invalid-escapes.rs:32:14
+ |
+LL | let _ = "\u8f";
+ | ^^^-
+ | |
+ | help: format of unicode escape sequences uses braces: `\u{8f}`
+
+error: aborting due to 13 previous errors
+
--- /dev/null
+fn main() {
+ let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `[`
+}
--- /dev/null
+error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[`
+ --> $DIR/issue-24197.rs:2:12
+ |
+LL | let buf[0] = 0;
+ | ^ expected one of `:`, `;`, `=`, `@`, or `|`
+
+error: aborting due to previous error
+
--- /dev/null
+static tmp : [&'static str; 2] = ["hello", "he"];
+
+fn main() {
+ let z = "hello";
+ match z {
+ tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[`
+ _ => {}
+ }
+}
--- /dev/null
+error: expected one of `=>`, `@`, `if`, or `|`, found `[`
+ --> $DIR/issue-24375.rs:6:12
+ |
+LL | tmp[0] => {}
+ | ^ expected one of `=>`, `@`, `if`, or `|`
+
+error: aborting due to previous error
+
--- /dev/null
+// Verify that '>' is not both expected and found at the same time, as it used
+// to happen in #24780. For example, following should be an error:
+// expected one of ..., `>`, ... found `>`.
+
+fn foo() -> Vec<usize>> { //~ ERROR expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
+ Vec::new()
+}
+
+fn main() {}
--- /dev/null
+error: expected one of `!`, `+`, `::`, `;`, `where`, or `{`, found `>`
+ --> $DIR/issue-24780.rs:5:23
+ |
+LL | fn foo() -> Vec<usize>> {
+ | ^ expected one of `!`, `+`, `::`, `;`, `where`, or `{`
+
+error: aborting due to previous error
+
--- /dev/null
+trait A {}
+
+impl A .. {}
+//~^ ERROR missing `for` in a trait impl
+//~| ERROR `impl Trait for .. {}` is an obsolete syntax
+
+impl A usize {}
+//~^ ERROR missing `for` in a trait impl
+
+fn main() {}
--- /dev/null
+error: missing `for` in a trait impl
+ --> $DIR/issue-27255.rs:3:7
+ |
+LL | impl A .. {}
+ | ^ help: add `for` here
+
+error: missing `for` in a trait impl
+ --> $DIR/issue-27255.rs:7:7
+ |
+LL | impl A usize {}
+ | ^^^^^^ help: add `for` here
+
+error: `impl Trait for .. {}` is an obsolete syntax
+ --> $DIR/issue-27255.rs:3:1
+ |
+LL | impl A .. {}
+ | ^^^^^^^^^^^^
+ |
+ = help: use `auto trait Trait {}` instead
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// run-rustfix
+#![allow(unused)]
+fn foo() { }
+
+/// Misplaced comment...
+//~^ ERROR expected outer doc comment
+fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function
+
+#[test] //~ ERROR an inner attribute is not permitted in this context
+fn baz() { } //~ NOTE the inner attribute doesn't annotate this function
+//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually
+
+/** Misplaced comment... */
+//~^ ERROR expected outer doc comment
+fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function
+
+fn main() { }
+
+// Misplaced comment...
+//~^ ERROR expected outer doc comment
+//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
+//~| NOTE other attributes here
+/* Misplaced comment... */
+//~^ ERROR expected outer doc comment
+//~| NOTE this doc comment doesn't document anything
+//~| ERROR expected item after doc comment
+//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
--- /dev/null
+// run-rustfix
+#![allow(unused)]
+fn foo() { }
+
+//! Misplaced comment...
+//~^ ERROR expected outer doc comment
+fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function
+
+#![test] //~ ERROR an inner attribute is not permitted in this context
+fn baz() { } //~ NOTE the inner attribute doesn't annotate this function
+//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually
+
+/*! Misplaced comment... */
+//~^ ERROR expected outer doc comment
+fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function
+
+fn main() { }
+
+//! Misplaced comment...
+//~^ ERROR expected outer doc comment
+//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
+//~| NOTE other attributes here
+/*! Misplaced comment... */
+//~^ ERROR expected outer doc comment
+//~| NOTE this doc comment doesn't document anything
+//~| ERROR expected item after doc comment
+//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
--- /dev/null
+error[E0753]: expected outer doc comment
+ --> $DIR/issue-30318.rs:5:1
+ |
+LL | //! Misplaced comment...
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | fn bar() { }
+ | ------------ the inner doc comment doesn't annotate this function
+ |
+help: to annotate the function, change the doc comment from inner to outer style
+ |
+LL | /// Misplaced comment...
+ | ~
+
+error: an inner attribute is not permitted in this context
+ --> $DIR/issue-30318.rs:9:1
+ |
+LL | #![test]
+ | ^^^^^^^^
+LL | fn baz() { }
+ | ------------ the inner attribute doesn't annotate this function
+ |
+ = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
+help: to annotate the function, change the attribute from inner to outer style
+ |
+LL - #![test]
+LL + #[test]
+ |
+
+error[E0753]: expected outer doc comment
+ --> $DIR/issue-30318.rs:13:1
+ |
+LL | /*! Misplaced comment... */
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | fn bat() { }
+ | ------------ the inner doc comment doesn't annotate this function
+ |
+help: to annotate the function, change the doc comment from inner to outer style
+ |
+LL | /** Misplaced comment... */
+ | ~
+
+error[E0753]: expected outer doc comment
+ --> $DIR/issue-30318.rs:19:1
+ |
+LL | //! Misplaced comment...
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
+help: you might have meant to write a regular comment
+ |
+LL - //! Misplaced comment...
+LL + // Misplaced comment...
+ |
+
+error[E0753]: expected outer doc comment
+ --> $DIR/issue-30318.rs:23:1
+ |
+LL | /*! Misplaced comment... */
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items
+help: you might have meant to write a regular comment
+ |
+LL - /*! Misplaced comment... */
+LL + /* Misplaced comment... */
+ |
+
+error: expected item after doc comment
+ --> $DIR/issue-30318.rs:23:1
+ |
+LL | //! Misplaced comment...
+ | ------------------------ other attributes here
+...
+LL | /*! Misplaced comment... */
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment doesn't document anything
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0753`.
--- /dev/null
+// run-rustfix
+
+// Testing that semicolon tokens are printed correctly in errors
+
+fn main() {
+ let _x = 3; //~ ERROR: expected `;`
+}
--- /dev/null
+// run-rustfix
+
+// Testing that semicolon tokens are printed correctly in errors
+
+fn main() {
+ let _x = 3 //~ ERROR: expected `;`
+}
--- /dev/null
+error: expected `;`, found `}`
+ --> $DIR/issue-3036.rs:6:15
+ |
+LL | let _x = 3
+ | ^ help: add `;` here
+LL | }
+ | - unexpected token
+
+error: aborting due to previous error
+
--- /dev/null
+// Test that error recovery in the parser to an EOF does not give an infinite
+// spew of errors.
+
+fn main() {
+ let
+} //~ ERROR expected pattern, found `}`
--- /dev/null
+error: expected pattern, found `}`
+ --> $DIR/issue-31804.rs:6:1
+ |
+LL | }
+ | ^ expected pattern
+
+error: aborting due to previous error
+
--- /dev/null
+trait Trait<T> { type Item; }
+
+pub fn test<W, I: Trait<Item=(), W> >() {}
+//~^ ERROR generic arguments must come before the first constraint
+
+fn main() { }
--- /dev/null
+error: generic arguments must come before the first constraint
+ --> $DIR/issue-32214.rs:3:34
+ |
+LL | pub fn test<W, I: Trait<Item=(), W> >() {}
+ | ------- ^ generic argument
+ | |
+ | constraint
+ |
+help: move the constraint after the generic argument
+ |
+LL | pub fn test<W, I: Trait<W, Item = ()> >() {}
+ | ~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {}
+
+// This used to end up in an infite loop trying to bump past EOF.
+trait T { ... } //~ ERROR
--- /dev/null
+error: non-item in item list
+ --> $DIR/issue-32446.rs:4:11
+ |
+LL | trait T { ... }
+ | - ^^^ - item list ends here
+ | | |
+ | | non-item starts here
+ | item list starts here
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {
+ let a = 0;
+ let _b = 0;
+ let _ = 0;
+ let mut b = 0;
+ let mut _b = 0;
+ let mut _ = 0;
+ //~^ ERROR `mut` must be followed by a named binding
+}
--- /dev/null
+error: `mut` must be followed by a named binding
+ --> $DIR/issue-32501.rs:7:9
+ |
+LL | let mut _ = 0;
+ | ^^^^^ help: remove the `mut` prefix: `_`
+ |
+ = note: `mut` may be followed by `variable` and `variable @ pattern`
+
+error: aborting due to previous error
+
--- /dev/null
+pub fn test() {
+ foo(|_|) //~ ERROR expected expression, found `)`
+}
+
+fn main() { }
--- /dev/null
+error: expected expression, found `)`
+ --> $DIR/issue-32505.rs:2:12
+ |
+LL | foo(|_|)
+ | ^ expected expression
+
+error: aborting due to previous error
+
--- /dev/null
+// Issue #33262
+
+pub fn main() {
+ for i in 0..a as { }
+ //~^ ERROR expected type, found `{`
+}
--- /dev/null
+error: expected type, found `{`
+ --> $DIR/issue-33262.rs:4:22
+ |
+LL | for i in 0..a as { }
+ | ^ expected type
+
+error: aborting due to previous error
+
--- /dev/null
+struct S;
+
+impl S {
+ fn f(*, a: u8) -> u8 {}
+ //~^ ERROR expected parameter name, found `*`
+ //~| ERROR mismatched types
+}
+
+fn main() {}
--- /dev/null
+error: expected parameter name, found `*`
+ --> $DIR/issue-33413.rs:4:10
+ |
+LL | fn f(*, a: u8) -> u8 {}
+ | ^ expected parameter name
+
+error[E0308]: mismatched types
+ --> $DIR/issue-33413.rs:4:23
+ |
+LL | fn f(*, a: u8) -> u8 {}
+ | - ^^ expected `u8`, found `()`
+ | |
+ | implicitly returns `()` as its body has no tail or `return` expression
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// run-rustfix
+
+trait Tr {}
+//~^ ERROR negative bounds are not supported
+trait Tr2: SuperA {}
+//~^ ERROR negative bounds are not supported
+trait Tr3: SuperB {}
+//~^ ERROR negative bounds are not supported
+trait Tr4: SuperB + SuperD {}
+//~^ ERROR negative bounds are not supported
+trait Tr5 {}
+//~^ ERROR negative bounds are not supported
+
+trait SuperA {}
+trait SuperB {}
+trait SuperC {}
+trait SuperD {}
+
+fn main() {}
--- /dev/null
+// run-rustfix
+
+trait Tr: !SuperA {}
+//~^ ERROR negative bounds are not supported
+trait Tr2: SuperA + !SuperB {}
+//~^ ERROR negative bounds are not supported
+trait Tr3: !SuperA + SuperB {}
+//~^ ERROR negative bounds are not supported
+trait Tr4: !SuperA + SuperB
+ + !SuperC + SuperD {}
+//~^ ERROR negative bounds are not supported
+trait Tr5: !SuperA
+ + !SuperB {}
+//~^ ERROR negative bounds are not supported
+
+trait SuperA {}
+trait SuperB {}
+trait SuperC {}
+trait SuperD {}
+
+fn main() {}
--- /dev/null
+error: negative bounds are not supported
+ --> $DIR/issue-33418.rs:3:9
+ |
+LL | trait Tr: !SuperA {}
+ | ^^^^^^^^^ negative bounds are not supported
+
+error: negative bounds are not supported
+ --> $DIR/issue-33418.rs:5:19
+ |
+LL | trait Tr2: SuperA + !SuperB {}
+ | ^^^^^^^^^ negative bounds are not supported
+
+error: negative bounds are not supported
+ --> $DIR/issue-33418.rs:7:10
+ |
+LL | trait Tr3: !SuperA + SuperB {}
+ | ^^^^^^^^^ negative bounds are not supported
+
+error: negative bounds are not supported
+ --> $DIR/issue-33418.rs:9:10
+ |
+LL | trait Tr4: !SuperA + SuperB
+ | ^^^^^^^^^
+LL | + !SuperC + SuperD {}
+ | ^^^^^^^^^ negative bounds are not supported
+
+error: negative bounds are not supported
+ --> $DIR/issue-33418.rs:12:10
+ |
+LL | trait Tr5: !SuperA
+ | ^^^^^^^^^
+LL | + !SuperB {}
+ | ^^^^^^^^^ negative bounds are not supported
+
+error: aborting due to 5 previous errors
+
--- /dev/null
+use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.`
--- /dev/null
+error: expected one of `::`, `;`, or `as`, found `.`
+ --> $DIR/issue-33455.rs:1:8
+ |
+LL | use foo.bar;
+ | ^ expected one of `::`, `;`, or `as`
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {
+ /// comment //~ ERROR found a documentation comment that doesn't document anything
+}
--- /dev/null
+error[E0585]: found a documentation comment that doesn't document anything
+ --> $DIR/issue-34222-1.rs:2:5
+ |
+LL | /// comment
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: doc comments must come before what they document, maybe a comment was intended with `//`?
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0585`.
--- /dev/null
+enum Test {
+ Drill {
+ field: i32,
+ }
+}
+
+fn main() {
+ Test::Drill(field: 42);
+ //~^ ERROR invalid `struct` delimiters or `fn` call arguments
+}
--- /dev/null
+error: invalid `struct` delimiters or `fn` call arguments
+ --> $DIR/issue-34255-1.rs:8:5
+ |
+LL | Test::Drill(field: 42);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: if `Test::Drill` is a struct, use braces as delimiters
+ |
+LL | Test::Drill { field: 42 };
+ | ~ ~
+help: if `Test::Drill` is a function, use the arguments directly
+ |
+LL - Test::Drill(field: 42);
+LL + Test::Drill(42);
+ |
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+#![crate_type = "lib"]
+#![feature(type_ascription)]
+use std::future::Future;
+use std::pin::Pin;
+
+// This tests the parser for "x as Y[z]". It errors, but we want to give useful
+// errors and parse such that further code gives useful errors.
+pub fn index_after_as_cast() {
+ vec![1, 2, 3] as Vec<i32>[0];
+ //~^ ERROR: casts cannot be followed by indexing
+ vec![1, 2, 3]: Vec<i32>[0];
+ //~^ ERROR: casts cannot be followed by indexing
+}
+
+pub fn index_after_cast_to_index() {
+ (&[0]) as &[i32][0];
+ //~^ ERROR: casts cannot be followed by indexing
+ (&[0i32]): &[i32; 1][0];
+ //~^ ERROR: casts cannot be followed by indexing
+}
+
+pub fn cast_after_cast() {
+ if 5u64 as i32 as u16 == 0u16 {
+
+ }
+ if 5u64: u64: u64 == 0u64 {
+
+ }
+ let _ = 5u64: u64: u64 as u8 as i8 == 9i8;
+ let _ = 0i32: i32: i32;
+ let _ = 0 as i32: i32;
+ let _ = 0i32: i32 as i32;
+ let _ = 0 as i32 as i32;
+ let _ = 0i32: i32: i32 as u32 as i32;
+}
+
+pub fn cast_cast_method_call() {
+ let _ = 0i32: i32: i32.count_ones();
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0 as i32: i32.count_ones();
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0i32: i32 as i32.count_ones();
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0 as i32 as i32.count_ones();
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0i32: i32: i32 as u32 as i32.count_ones();
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0i32: i32.count_ones(): u32;
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0 as i32.count_ones(): u32;
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0i32: i32.count_ones() as u32;
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0 as i32.count_ones() as u32;
+ //~^ ERROR: casts cannot be followed by a method call
+ let _ = 0i32: i32: i32.count_ones() as u32 as i32;
+ //~^ ERROR: casts cannot be followed by a method call
+}
+
+pub fn multiline_error() {
+ let _ = 0
+ as i32
+ .count_ones();
+ //~^^^ ERROR: casts cannot be followed by a method call
+}
+
+// this tests that the precedence for `!x as Y.Z` is still what we expect
+pub fn precedence() {
+ let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
+ //~^ ERROR: casts cannot be followed by indexing
+}
+
+pub fn method_calls() {
+ 0 as i32.max(0);
+ //~^ ERROR: casts cannot be followed by a method call
+ 0: i32.max(0);
+ //~^ ERROR: casts cannot be followed by a method call
+}
+
+pub fn complex() {
+ let _ = format!(
+ "{} and {}",
+ if true { 33 } else { 44 } as i32.max(0),
+ //~^ ERROR: casts cannot be followed by a method call
+ if true { 33 } else { 44 }: i32.max(0)
+ //~^ ERROR: casts cannot be followed by a method call
+ );
+}
+
+pub fn in_condition() {
+ if 5u64 as i32.max(0) == 0 {
+ //~^ ERROR: casts cannot be followed by a method call
+ }
+ if 5u64: u64.max(0) == 0 {
+ //~^ ERROR: casts cannot be followed by a method call
+ }
+}
+
+pub fn inside_block() {
+ let _ = if true {
+ 5u64 as u32.max(0) == 0
+ //~^ ERROR: casts cannot be followed by a method call
+ } else { false };
+ let _ = if true {
+ 5u64: u64.max(0) == 0
+ //~^ ERROR: casts cannot be followed by a method call
+ } else { false };
+}
+
+static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
+//~^ ERROR: casts cannot be followed by indexing
+
+static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
+//~^ ERROR: casts cannot be followed by indexing
+
+
+pub fn cast_then_try() -> Result<u64,u64> {
+ Err(0u64) as Result<u64,u64>?;
+ //~^ ERROR: casts cannot be followed by ?
+ Err(0u64): Result<u64,u64>?;
+ //~^ ERROR: casts cannot be followed by ?
+ Ok(1)
+}
+
+
+pub fn cast_then_call() {
+ type F = fn(u8);
+ // type ascription won't actually do [unique drop fn type] -> fn(u8) casts.
+ let drop_ptr = drop as fn(u8);
+ drop as F();
+ //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214]
+ drop_ptr: F();
+ //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214]
+}
+
+pub fn cast_to_fn_should_work() {
+ let drop_ptr = drop as fn(u8);
+ drop as fn(u8);
+ drop_ptr: fn(u8);
+}
+
+pub fn parens_after_cast_error() {
+ let drop_ptr = drop as fn(u8);
+ drop as fn(u8)(0);
+ //~^ ERROR: casts cannot be followed by a function call
+ drop_ptr: fn(u8)(0);
+ //~^ ERROR: casts cannot be followed by a function call
+}
+
+pub async fn cast_then_await() {
+ Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
+ //~^ ERROR: casts cannot be followed by `.await`
+
+ Box::pin(noop()): Pin<Box<_>>.await;
+ //~^ ERROR: casts cannot be followed by `.await`
+}
+
+pub async fn noop() {}
+
+#[derive(Default)]
+pub struct Foo {
+ pub bar: u32,
+}
+
+pub fn struct_field() {
+ Foo::default() as Foo.bar;
+ //~^ ERROR: cannot be followed by a field access
+ Foo::default(): Foo.bar;
+ //~^ ERROR: cannot be followed by a field access
+}
--- /dev/null
+error: casts cannot be followed by indexing
+ --> $DIR/issue-35813-postfix-after-cast.rs:10:5
+ |
+LL | vec![1, 2, 3] as Vec<i32>[0];
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (vec![1, 2, 3] as Vec<i32>)[0];
+ | + +
+
+error: casts cannot be followed by indexing
+ --> $DIR/issue-35813-postfix-after-cast.rs:12:5
+ |
+LL | vec![1, 2, 3]: Vec<i32>[0];
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (vec![1, 2, 3]: Vec<i32>)[0];
+ | + +
+
+error: casts cannot be followed by indexing
+ --> $DIR/issue-35813-postfix-after-cast.rs:17:5
+ |
+LL | (&[0]) as &[i32][0];
+ | ^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | ((&[0]) as &[i32])[0];
+ | + +
+
+error: casts cannot be followed by indexing
+ --> $DIR/issue-35813-postfix-after-cast.rs:19:5
+ |
+LL | (&[0i32]): &[i32; 1][0];
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | ((&[0i32]): &[i32; 1])[0];
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:39:13
+ |
+LL | let _ = 0i32: i32: i32.count_ones();
+ | ^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0i32: i32: i32).count_ones();
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:41:13
+ |
+LL | let _ = 0 as i32: i32.count_ones();
+ | ^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0 as i32: i32).count_ones();
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:43:13
+ |
+LL | let _ = 0i32: i32 as i32.count_ones();
+ | ^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0i32: i32 as i32).count_ones();
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:45:13
+ |
+LL | let _ = 0 as i32 as i32.count_ones();
+ | ^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0 as i32 as i32).count_ones();
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:47:13
+ |
+LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0i32: i32: i32 as u32 as i32).count_ones();
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:49:13
+ |
+LL | let _ = 0i32: i32.count_ones(): u32;
+ | ^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0i32: i32).count_ones(): u32;
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:51:13
+ |
+LL | let _ = 0 as i32.count_ones(): u32;
+ | ^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0 as i32).count_ones(): u32;
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:53:13
+ |
+LL | let _ = 0i32: i32.count_ones() as u32;
+ | ^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0i32: i32).count_ones() as u32;
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:55:13
+ |
+LL | let _ = 0 as i32.count_ones() as u32;
+ | ^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0 as i32).count_ones() as u32;
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:57:13
+ |
+LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32;
+ | ^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let _ = (0i32: i32: i32).count_ones() as u32 as i32;
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:62:13
+ |
+LL | let _ = 0
+ | _____________^
+LL | | as i32
+ | |______________^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL ~ let _ = (0
+LL ~ as i32)
+ |
+
+error: casts cannot be followed by indexing
+ --> $DIR/issue-35813-postfix-after-cast.rs:70:18
+ |
+LL | let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0];
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | let x: i32 = (&vec![1, 2, 3] as &Vec<i32>)[0];
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:75:5
+ |
+LL | 0 as i32.max(0);
+ | ^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (0 as i32).max(0);
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:77:5
+ |
+LL | 0: i32.max(0);
+ | ^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (0: i32).max(0);
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:92:8
+ |
+LL | if 5u64 as i32.max(0) == 0 {
+ | ^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | if (5u64 as i32).max(0) == 0 {
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:95:8
+ |
+LL | if 5u64: u64.max(0) == 0 {
+ | ^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | if (5u64: u64).max(0) == 0 {
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:102:9
+ |
+LL | 5u64 as u32.max(0) == 0
+ | ^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (5u64 as u32).max(0) == 0
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:106:9
+ |
+LL | 5u64: u64.max(0) == 0
+ | ^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (5u64: u64).max(0) == 0
+ | + +
+
+error: casts cannot be followed by indexing
+ --> $DIR/issue-35813-postfix-after-cast.rs:111:24
+ |
+LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]);
+ | ^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]);
+ | + +
+
+error: casts cannot be followed by indexing
+ --> $DIR/issue-35813-postfix-after-cast.rs:114:25
+ |
+LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | static bar2: &[i32] = &((&[1i32,2,3]: &[i32; 3])[0..1]);
+ | + +
+
+error: casts cannot be followed by ?
+ --> $DIR/issue-35813-postfix-after-cast.rs:119:5
+ |
+LL | Err(0u64) as Result<u64,u64>?;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (Err(0u64) as Result<u64,u64>)?;
+ | + +
+
+error: casts cannot be followed by ?
+ --> $DIR/issue-35813-postfix-after-cast.rs:121:5
+ |
+LL | Err(0u64): Result<u64,u64>?;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (Err(0u64): Result<u64,u64>)?;
+ | + +
+
+error: casts cannot be followed by a function call
+ --> $DIR/issue-35813-postfix-after-cast.rs:145:5
+ |
+LL | drop as fn(u8)(0);
+ | ^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (drop as fn(u8))(0);
+ | + +
+
+error: casts cannot be followed by a function call
+ --> $DIR/issue-35813-postfix-after-cast.rs:147:5
+ |
+LL | drop_ptr: fn(u8)(0);
+ | ^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (drop_ptr: fn(u8))(0);
+ | + +
+
+error: casts cannot be followed by `.await`
+ --> $DIR/issue-35813-postfix-after-cast.rs:152:5
+ |
+LL | Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await;
+ | + +
+
+error: casts cannot be followed by `.await`
+ --> $DIR/issue-35813-postfix-after-cast.rs:155:5
+ |
+LL | Box::pin(noop()): Pin<Box<_>>.await;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (Box::pin(noop()): Pin<Box<_>>).await;
+ | + +
+
+error: casts cannot be followed by a field access
+ --> $DIR/issue-35813-postfix-after-cast.rs:167:5
+ |
+LL | Foo::default() as Foo.bar;
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (Foo::default() as Foo).bar;
+ | + +
+
+error: casts cannot be followed by a field access
+ --> $DIR/issue-35813-postfix-after-cast.rs:169:5
+ |
+LL | Foo::default(): Foo.bar;
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (Foo::default(): Foo).bar;
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:84:9
+ |
+LL | if true { 33 } else { 44 } as i32.max(0),
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (if true { 33 } else { 44 } as i32).max(0),
+ | + +
+
+error: casts cannot be followed by a method call
+ --> $DIR/issue-35813-postfix-after-cast.rs:86:9
+ |
+LL | if true { 33 } else { 44 }: i32.max(0)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: try surrounding the expression in parentheses
+ |
+LL | (if true { 33 } else { 44 }: i32).max(0)
+ | + +
+
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+ --> $DIR/issue-35813-postfix-after-cast.rs:131:13
+ |
+LL | drop as F();
+ | ^^^ only `Fn` traits may use parentheses
+
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+ --> $DIR/issue-35813-postfix-after-cast.rs:133:15
+ |
+LL | drop_ptr: F();
+ | ^^^ only `Fn` traits may use parentheses
+
+error: aborting due to 36 previous errors
+
+For more information about this error, try `rustc --explain E0214`.
--- /dev/null
+struct S;
+
+impl S {
+ pub //~ ERROR visibility `pub` is not followed by an item
+} //~ ERROR non-item in item list
+
+fn main() {}
--- /dev/null
+error: visibility `pub` is not followed by an item
+ --> $DIR/issue-41155.rs:4:5
+ |
+LL | pub
+ | ^^^ the visibility
+ |
+ = help: you likely meant to define an item, e.g., `pub fn foo() {}`
+
+error: non-item in item list
+ --> $DIR/issue-41155.rs:5:1
+ |
+LL | impl S {
+ | - item list starts here
+LL | pub
+LL | }
+ | ^
+ | |
+ | non-item starts here
+ | item list ends here
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+fn main() {
+ |
+}
+//~^ ERROR expected `|`, found `}`
+|
+//~^ ERROR expected item, found `|`
--- /dev/null
+error: expected `|`, found `}`
+ --> $DIR/issue-43196.rs:3:1
+ |
+LL | |
+ | - expected `|`
+LL | }
+ | ^ unexpected token
+
+error: expected item, found `|`
+ --> $DIR/issue-43196.rs:5:1
+ |
+LL | |
+ | ^ expected item
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+fn main() {
+ '\u{_10FFFF}'; //~ ERROR invalid start of unicode escape
+}
--- /dev/null
+error: invalid start of unicode escape: `_`
+ --> $DIR/issue-43692.rs:2:9
+ |
+LL | '\u{_10FFFF}';
+ | ^ invalid start of unicode escape
+
+error: aborting due to previous error
+
--- /dev/null
+struct MyStruct;
+impl MyStruct {
+ fn f() {|x, y} //~ ERROR expected one of `:`, `@`, or `|`, found `}`
+}
+
+fn main() {}
--- /dev/null
+error: expected one of `:`, `@`, or `|`, found `}`
+ --> $DIR/issue-44021.rs:3:18
+ |
+LL | fn f() {|x, y}
+ | ^ expected one of `:`, `@`, or `|`
+
+error: aborting due to previous error
+
--- /dev/null
+macro_rules! foo {
+ ($rest: tt) => {
+ bar(baz: $rest) //~ ERROR invalid `struct` delimiters or `fn` call arguments
+ }
+}
+
+fn main() {
+ foo!(true);
+ //~^ ERROR expected identifier, found keyword
+}
--- /dev/null
+error: expected identifier, found keyword `true`
+ --> $DIR/issue-44406.rs:8:10
+ |
+LL | foo!(true);
+ | ^^^^ expected identifier, found keyword
+ |
+help: you can escape reserved keywords to use them as identifiers
+ |
+LL | foo!(r#true);
+ | ~~~~~~
+
+error: invalid `struct` delimiters or `fn` call arguments
+ --> $DIR/issue-44406.rs:3:9
+ |
+LL | bar(baz: $rest)
+ | ^^^^^^^^^^^^^^^
+...
+LL | foo!(true);
+ | ---------- in this macro invocation
+ |
+ = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: if `bar` is a struct, use braces as delimiters
+ |
+LL | bar { }
+ | ~
+help: if `bar` is a function, use the arguments directly
+ |
+LL - bar(baz: $rest)
+LL + bar(: $rest)
+ |
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+fn main() {
+ let unused = ();
+
+ #![allow(unused_variables)] //~ ERROR not permitted in this context
+ fn foo() {}
+}
--- /dev/null
+error: an inner attribute is not permitted in this context
+ --> $DIR/issue-45296.rs:4:5
+ |
+LL | #![allow(unused_variables)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | fn foo() {}
+ | ----------- the inner attribute doesn't annotate this function
+ |
+ = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
+help: to annotate the function, change the attribute from inner to outer style
+ |
+LL - #![allow(unused_variables)]
+LL + #[allow(unused_variables)]
+ |
+
+error: aborting due to previous error
+
--- /dev/null
+// run-rustfix
+
+pub struct Struct {
+ pub a: usize,
+}
+//~^ ERROR expected item, found `;`
+
+fn main() {}
--- /dev/null
+// run-rustfix
+
+pub struct Struct {
+ pub a: usize,
+};
+//~^ ERROR expected item, found `;`
+
+fn main() {}
--- /dev/null
+error: expected item, found `;`
+ --> $DIR/issue-46186.rs:5:2
+ |
+LL | };
+ | ^ help: remove this semicolon
+ |
+ = help: braced struct declarations are not followed by a semicolon
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {}
+
+macro_rules! expand_to_enum {
+ () => {
+ enum BadE {}
+ //~^ ERROR enum is not supported in `trait`s or `impl`s
+ //~| ERROR enum is not supported in `trait`s or `impl`s
+ //~| ERROR enum is not supported in `extern` blocks
+ };
+}
+
+macro_rules! mac_impl {
+ ($($i:item)*) => {
+ struct S;
+ impl S { $($i)* }
+ }
+}
+
+mac_impl! {
+ struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s
+ expand_to_enum!();
+}
+
+macro_rules! mac_trait {
+ ($($i:item)*) => {
+ trait T { $($i)* }
+ }
+}
+
+mac_trait! {
+ struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s
+ expand_to_enum!();
+}
+
+macro_rules! mac_extern {
+ ($($i:item)*) => {
+ extern "C" { $($i)* }
+ }
+}
+
+mac_extern! {
+ struct BadS; //~ ERROR struct is not supported in `extern` blocks
+ expand_to_enum!();
+}
--- /dev/null
+error: struct is not supported in `trait`s or `impl`s
+ --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:20:5
+ |
+LL | struct BadS;
+ | ^^^^^^^^^^^^
+ |
+ = help: consider moving the struct out to a nearby module scope
+
+error: enum is not supported in `trait`s or `impl`s
+ --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
+ |
+LL | enum BadE {}
+ | ^^^^^^^^^
+...
+LL | expand_to_enum!();
+ | ----------------- in this macro invocation
+ |
+ = help: consider moving the enum out to a nearby module scope
+ = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: struct is not supported in `trait`s or `impl`s
+ --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:31:5
+ |
+LL | struct BadS;
+ | ^^^^^^^^^^^^
+ |
+ = help: consider moving the struct out to a nearby module scope
+
+error: enum is not supported in `trait`s or `impl`s
+ --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
+ |
+LL | enum BadE {}
+ | ^^^^^^^^^
+...
+LL | expand_to_enum!();
+ | ----------------- in this macro invocation
+ |
+ = help: consider moving the enum out to a nearby module scope
+ = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: struct is not supported in `extern` blocks
+ --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:42:5
+ |
+LL | struct BadS;
+ | ^^^^^^^^^^^^
+ |
+ = help: consider moving the struct out to a nearby module scope
+
+error: enum is not supported in `extern` blocks
+ --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
+ |
+LL | enum BadE {}
+ | ^^^^^^^^^
+...
+LL | expand_to_enum!();
+ | ----------------- in this macro invocation
+ |
+ = help: consider moving the enum out to a nearby module scope
+ = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 6 previous errors
+
--- /dev/null
+// check-pass
+
+fn main() {}
+
+macro_rules! mac_impl {
+ ($i:item) => {
+ struct S;
+ impl S { $i }
+ }
+}
+
+mac_impl! {
+ fn foo() {}
+}
+
+macro_rules! mac_trait {
+ ($i:item) => {
+ trait T { $i }
+ }
+}
+
+mac_trait! {
+ fn foo() {}
+}
+
+macro_rules! mac_extern {
+ ($i:item) => {
+ extern "C" { $i }
+ }
+}
+
+mac_extern! {
+ fn foo();
+}
--- /dev/null
+// run-pass
+// ignore-test Not a test. Used by issue-48508.rs
+
+pub fn other() -> f64 {
+ let µ = 1.0;
+ µ
+}
--- /dev/null
+// run-pass
+// Regression test for issue #48508:
+//
+// Confusion between global and local file offsets caused incorrect handling of multibyte character
+// spans when compiling multiple files. One visible effect was an ICE generating debug information
+// when a multibyte character is at the end of a scope. The problematic code is actually in
+// issue-48508-aux.rs
+
+// compile-flags:-g
+// ignore-pretty issue #37195
+// ignore-asmjs wasm2js does not support source maps yet
+
+#![allow(uncommon_codepoints)]
+
+#[path = "issue-48508-aux.rs"]
+mod other_file;
+
+fn main() {
+ other_file::other();
+}
--- /dev/null
+// run-rustfix
+
+#![allow(dead_code)]
+
+struct S {
+ x: u8,
+ /// The ID of the parent core
+ y: u8,
+}
+//~^^^ ERROR found a documentation comment that doesn't document anything
+
+fn main() {}
--- /dev/null
+// run-rustfix
+
+#![allow(dead_code)]
+
+struct S {
+ x: u8
+ /// The ID of the parent core
+ y: u8,
+}
+//~^^^ ERROR found a documentation comment that doesn't document anything
+
+fn main() {}
--- /dev/null
+error[E0585]: found a documentation comment that doesn't document anything
+ --> $DIR/issue-48636.rs:7:5
+ |
+LL | x: u8
+ | - help: missing comma here: `,`
+LL | /// The ID of the parent core
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: doc comments must come before what they document, maybe a comment was intended with `//`?
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0585`.
--- /dev/null
+#![allow(unused_variables)]; //~ ERROR expected item, found `;`
+//~^ ERROR `main` function
+fn foo() {}
--- /dev/null
+error: expected item, found `;`
+ --> $DIR/issue-49040.rs:1:28
+ |
+LL | #![allow(unused_variables)];
+ | ^ help: remove this semicolon
+
+error[E0601]: `main` function not found in crate `issue_49040`
+ --> $DIR/issue-49040.rs:1:1
+ |
+LL | #![allow(unused_variables)];
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `$DIR/issue-49040.rs`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0601`.
--- /dev/null
+fn main(){
+ if i in 1..10 {
+//~^ ERROR expected `{`, found keyword `in`
+ break;
+ }
+}
--- /dev/null
+error: expected `{`, found keyword `in`
+ --> $DIR/issue-51602.rs:2:10
+ |
+LL | if i in 1..10 {
+ | -- ^^ expected `{`
+ | |
+ | this `if` expression has a condition, but no block
+
+error: aborting due to previous error
+
--- /dev/null
+struct Foo { bar: f64, baz: i64, bat: i64 }
+
+fn main() {
+ let _ = Foo { bar: .5, baz: 42 };
+ //~^ ERROR float literals must have an integer part
+ //~| ERROR missing field `bat` in initializer of `Foo`
+ let bar = 1.5f32;
+ let _ = Foo { bar.into(), bat: -1, . };
+ //~^ ERROR expected one of
+ //~| ERROR missing fields `bar` and `baz` in initializer of `Foo`
+ //~| ERROR expected identifier, found `.`
+}
--- /dev/null
+error: float literals must have an integer part
+ --> $DIR/issue-52496.rs:4:24
+ |
+LL | let _ = Foo { bar: .5, baz: 42 };
+ | ^^ help: must have an integer part: `0.5`
+
+error: expected one of `,` or `}`, found `.`
+ --> $DIR/issue-52496.rs:8:22
+ |
+LL | let _ = Foo { bar.into(), bat: -1, . };
+ | --- ^ expected one of `,` or `}`
+ | |
+ | while parsing this struct
+
+error: expected identifier, found `.`
+ --> $DIR/issue-52496.rs:8:40
+ |
+LL | let _ = Foo { bar.into(), bat: -1, . };
+ | --- ^ expected identifier
+ | |
+ | while parsing this struct
+
+error[E0063]: missing field `bat` in initializer of `Foo`
+ --> $DIR/issue-52496.rs:4:13
+ |
+LL | let _ = Foo { bar: .5, baz: 42 };
+ | ^^^ missing `bat`
+
+error[E0063]: missing fields `bar` and `baz` in initializer of `Foo`
+ --> $DIR/issue-52496.rs:8:13
+ |
+LL | let _ = Foo { bar.into(), bat: -1, . };
+ | ^^^ missing `bar` and `baz`
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0063`.
--- /dev/null
+// check-pass
+
+// This test checks that the `remove extra angle brackets` error doesn't happen for some
+// potential edge-cases..
+
+struct X {
+ len: u32,
+}
+
+fn main() {
+ let x = X { len: 3 };
+
+ let _ = x.len > (3);
+
+ let _ = x.len >> (3);
+}
--- /dev/null
+// run-rustfix
+
+// This test checks that the following error is emitted and the suggestion works:
+//
+// ```
+// let _ = Vec::<usize>>>::new();
+// ^^ help: remove extra angle brackets
+// ```
+
+fn main() {
+ let _ = Vec::<usize>::new();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = Vec::<usize>::new();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = Vec::<usize>::new();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = Vec::<usize>::new();
+ //~^ ERROR unmatched angle bracket
+}
--- /dev/null
+// run-rustfix
+
+// This test checks that the following error is emitted and the suggestion works:
+//
+// ```
+// let _ = Vec::<usize>>>::new();
+// ^^ help: remove extra angle brackets
+// ```
+
+fn main() {
+ let _ = Vec::<usize>>>>>::new();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = Vec::<usize>>>>::new();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = Vec::<usize>>>::new();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = Vec::<usize>>::new();
+ //~^ ERROR unmatched angle bracket
+}
--- /dev/null
+error: unmatched angle brackets
+ --> $DIR/issue-54521-2.rs:11:25
+ |
+LL | let _ = Vec::<usize>>>>>::new();
+ | ^^^^ help: remove extra angle brackets
+
+error: unmatched angle brackets
+ --> $DIR/issue-54521-2.rs:14:25
+ |
+LL | let _ = Vec::<usize>>>>::new();
+ | ^^^ help: remove extra angle brackets
+
+error: unmatched angle brackets
+ --> $DIR/issue-54521-2.rs:17:25
+ |
+LL | let _ = Vec::<usize>>>::new();
+ | ^^ help: remove extra angle brackets
+
+error: unmatched angle bracket
+ --> $DIR/issue-54521-2.rs:20:25
+ |
+LL | let _ = Vec::<usize>>::new();
+ | ^ help: remove extra angle bracket
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// run-rustfix
+
+// This test checks that the following error is emitted and the suggestion works:
+//
+// ```
+// let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
+// ^^ help: remove extra angle brackets
+// ```
+
+fn main() {
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+}
--- /dev/null
+// run-rustfix
+
+// This test checks that the following error is emitted and the suggestion works:
+//
+// ```
+// let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
+// ^^ help: remove extra angle brackets
+// ```
+
+fn main() {
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>();
+ //~^ ERROR unmatched angle bracket
+}
--- /dev/null
+error: unmatched angle brackets
+ --> $DIR/issue-54521-3.rs:11:60
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>>();
+ | ^^^^ help: remove extra angle brackets
+
+error: unmatched angle brackets
+ --> $DIR/issue-54521-3.rs:14:60
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>();
+ | ^^^ help: remove extra angle brackets
+
+error: unmatched angle brackets
+ --> $DIR/issue-54521-3.rs:17:60
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>();
+ | ^^ help: remove extra angle brackets
+
+error: unmatched angle bracket
+ --> $DIR/issue-54521-3.rs:20:60
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>();
+ | ^ help: remove extra angle bracket
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+fn main() {
+ let __isize = 340282366920938463463374607431768211456; // 2^128
+ //~^ ERROR integer literal is too large
+}
--- /dev/null
+error: integer literal is too large
+ --> $DIR/issue-5544-a.rs:2:19
+ |
+LL | let __isize = 340282366920938463463374607431768211456; // 2^128
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {
+ let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff;
+ //~^ ERROR integer literal is too large
+}
--- /dev/null
+error: integer literal is too large
+ --> $DIR/issue-5544-b.rs:2:19
+ |
+LL | let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+struct T;
+
+impl for T {}
+//~^ ERROR missing trait in a trait impl
+
+fn main() {}
--- /dev/null
+error: missing trait in a trait impl
+ --> $DIR/issue-56031.rs:3:5
+ |
+LL | impl for T {}
+ | ^
+ |
+help: add a trait here
+ |
+LL | impl Trait for T {}
+ | +++++
+help: for an inherent impl, drop this `for`
+ |
+LL - impl for T {}
+LL + impl T {}
+ |
+
+error: aborting due to previous error
+
--- /dev/null
+mod m {
+ pub fn r#for() {}
+}
+
+fn main() {
+ m::for();
+ //~^ ERROR expected identifier, found keyword `for`
+}
--- /dev/null
+error: expected identifier, found keyword `for`
+ --> $DIR/issue-57198.rs:6:8
+ |
+LL | m::for();
+ | ^^^ expected identifier, found keyword
+ |
+help: you can escape reserved keywords to use them as identifiers
+ |
+LL | m::r#for();
+ | ~~~~~
+
+error: aborting due to previous error
+
--- /dev/null
+// run-rustfix
+
+#![allow(warnings)]
+
+// This test checks that the following error is emitted when a `=` character is used to initialize
+// a struct field when a `:` is expected.
+//
+// ```
+// error: struct fields are initialized with a colon
+// --> $DIR/issue-57684.rs:12:20
+// |
+// LL | let _ = X { f1 = 5 };
+// | ^ help: replace equals symbol with a colon: `:`
+// ```
+
+struct X {
+ f1: i32,
+}
+
+struct Y {
+ f1: i32,
+ f2: i32,
+ f3: i32,
+}
+
+fn main() {
+ let _ = X { f1: 5 };
+ //~^ ERROR expected `:`, found `=`
+
+ let f3 = 3;
+ let _ = Y {
+ f1: 5,
+ //~^ ERROR expected `:`, found `=`
+ f2: 4,
+ f3,
+ };
+}
--- /dev/null
+// run-rustfix
+
+#![allow(warnings)]
+
+// This test checks that the following error is emitted when a `=` character is used to initialize
+// a struct field when a `:` is expected.
+//
+// ```
+// error: struct fields are initialized with a colon
+// --> $DIR/issue-57684.rs:12:20
+// |
+// LL | let _ = X { f1 = 5 };
+// | ^ help: replace equals symbol with a colon: `:`
+// ```
+
+struct X {
+ f1: i32,
+}
+
+struct Y {
+ f1: i32,
+ f2: i32,
+ f3: i32,
+}
+
+fn main() {
+ let _ = X { f1 = 5 };
+ //~^ ERROR expected `:`, found `=`
+
+ let f3 = 3;
+ let _ = Y {
+ f1 = 5,
+ //~^ ERROR expected `:`, found `=`
+ f2: 4,
+ f3,
+ };
+}
--- /dev/null
+error: expected `:`, found `=`
+ --> $DIR/issue-57684.rs:27:20
+ |
+LL | let _ = X { f1 = 5 };
+ | -^
+ | |
+ | help: replace equals symbol with a colon: `:`
+
+error: expected `:`, found `=`
+ --> $DIR/issue-57684.rs:32:12
+ |
+LL | f1 = 5,
+ | -^
+ | |
+ | help: replace equals symbol with a colon: `:`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// run-rustfix
+
+#![allow(warnings)]
+
+// This test checks that the following error is emitted and the suggestion works:
+//
+// ```
+// let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
+// ^^ help: remove extra angle brackets
+// ```
+
+trait Foo {
+ type Output;
+}
+
+fn foo<T: Foo>() {
+ // More complex cases with more than one correct leading `<` character:
+
+ bar::<<T as Foo>::Output>();
+ //~^ ERROR unmatched angle bracket
+
+ bar::<<T as Foo>::Output>();
+ //~^ ERROR unmatched angle bracket
+
+ bar::<<T as Foo>::Output>();
+ //~^ ERROR unmatched angle bracket
+
+ bar::<<T as Foo>::Output>();
+}
+
+fn bar<T>() {}
+
+fn main() {
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+}
--- /dev/null
+// run-rustfix
+
+#![allow(warnings)]
+
+// This test checks that the following error is emitted and the suggestion works:
+//
+// ```
+// let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
+// ^^ help: remove extra angle brackets
+// ```
+
+trait Foo {
+ type Output;
+}
+
+fn foo<T: Foo>() {
+ // More complex cases with more than one correct leading `<` character:
+
+ bar::<<<<<T as Foo>::Output>();
+ //~^ ERROR unmatched angle bracket
+
+ bar::<<<<T as Foo>::Output>();
+ //~^ ERROR unmatched angle bracket
+
+ bar::<<<T as Foo>::Output>();
+ //~^ ERROR unmatched angle bracket
+
+ bar::<<T as Foo>::Output>();
+}
+
+fn bar<T>() {}
+
+fn main() {
+ let _ = vec![1, 2, 3].into_iter().collect::<<<<<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<<<<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<<Vec<usize>>();
+ //~^ ERROR unmatched angle bracket
+
+ let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>();
+}
--- /dev/null
+error: unmatched angle brackets
+ --> $DIR/issue-57819.rs:19:10
+ |
+LL | bar::<<<<<T as Foo>::Output>();
+ | ^^^ help: remove extra angle brackets
+
+error: unmatched angle brackets
+ --> $DIR/issue-57819.rs:22:10
+ |
+LL | bar::<<<<T as Foo>::Output>();
+ | ^^ help: remove extra angle brackets
+
+error: unmatched angle bracket
+ --> $DIR/issue-57819.rs:25:10
+ |
+LL | bar::<<<T as Foo>::Output>();
+ | ^ help: remove extra angle bracket
+
+error: unmatched angle brackets
+ --> $DIR/issue-57819.rs:34:48
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<<<<<Vec<usize>>();
+ | ^^^^ help: remove extra angle brackets
+
+error: unmatched angle brackets
+ --> $DIR/issue-57819.rs:37:48
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<<<<Vec<usize>>();
+ | ^^^ help: remove extra angle brackets
+
+error: unmatched angle brackets
+ --> $DIR/issue-57819.rs:40:48
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
+ | ^^ help: remove extra angle brackets
+
+error: unmatched angle bracket
+ --> $DIR/issue-57819.rs:43:48
+ |
+LL | let _ = vec![1, 2, 3].into_iter().collect::<<Vec<usize>>();
+ | ^ help: remove extra angle bracket
+
+error: aborting due to 7 previous errors
+
--- /dev/null
+// normalize-stderr-test: "parser:.*\(" -> "parser: $$ACCESS_DENIED_MSG ("
+// normalize-stderr-test: "os error \d+" -> "os error $$ACCESS_DENIED_CODE"
+
+#[path = "../parser"]
+mod foo; //~ ERROR couldn't read
+
+fn main() {}
--- /dev/null
+error: couldn't read $DIR/../parser: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE)
+ --> $DIR/issue-5806.rs:5:1
+ |
+LL | mod foo;
+ | ^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// Fixed in #66054.
+// ignore-tidy-trailing-newlines
+// error-pattern: aborting due to 2 previous errors
+#[Ѕ
\ No newline at end of file
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-58094-missing-right-square-bracket.rs:4:4
+ |
+LL | #[Ѕ
+ | - ^
+ | |
+ | unclosed delimiter
+
+error: expected item after attributes
+ --> $DIR/issue-58094-missing-right-square-bracket.rs:4:1
+ |
+LL | #[Ѕ
+ | ^^^
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+impl A {
+ //~^ ERROR cannot find type `A` in this scope
+ fn b(self>
+ //~^ ERROR expected one of `)`, `,`, or `:`, found `>`
+ //~| ERROR expected one of `->`, `;`, `where`, or `{`, found `>`
+}
+
+fn main() {}
--- /dev/null
+error: expected one of `)`, `,`, or `:`, found `>`
+ --> $DIR/issue-58856-1.rs:3:9
+ |
+LL | fn b(self>
+ | ^ ^ help: `)` may belong here
+ | |
+ | unclosed delimiter
+
+error: expected one of `->`, `;`, `where`, or `{`, found `>`
+ --> $DIR/issue-58856-1.rs:3:14
+ |
+LL | impl A {
+ | - while parsing this item list starting here
+LL |
+LL | fn b(self>
+ | ^ expected one of `->`, `;`, `where`, or `{`
+...
+LL | }
+ | - the item list ends here
+
+error[E0412]: cannot find type `A` in this scope
+ --> $DIR/issue-58856-1.rs:1:6
+ |
+LL | impl A {
+ | ^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0412`.
--- /dev/null
+struct Empty;
+
+trait Howness {}
+
+impl Howness for () {
+ fn how_are_you(&self -> Empty {
+ //~^ ERROR expected one of `)` or `,`, found `->`
+ //~| ERROR method `how_are_you` is not a member of trait `Howness`
+ Empty
+ }
+}
+//~^ ERROR non-item in item list
+
+fn main() {}
--- /dev/null
+error: expected one of `)` or `,`, found `->`
+ --> $DIR/issue-58856-2.rs:6:19
+ |
+LL | fn how_are_you(&self -> Empty {
+ | ^ -^^
+ | | |
+ | | help: `)` may belong here
+ | unclosed delimiter
+
+error: non-item in item list
+ --> $DIR/issue-58856-2.rs:11:1
+ |
+LL | impl Howness for () {
+ | - item list starts here
+...
+LL | }
+ | ^
+ | |
+ | non-item starts here
+ | item list ends here
+
+error[E0407]: method `how_are_you` is not a member of trait `Howness`
+ --> $DIR/issue-58856-2.rs:6:5
+ |
+LL | / fn how_are_you(&self -> Empty {
+LL | |
+LL | |
+LL | | Empty
+LL | | }
+ | |_____^ not a member of trait `Howness`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0407`.
--- /dev/null
+struct X(i32,i32,i32);
+
+fn main() {
+ let a = X(1, 2, 3);
+ let b = a.1suffix;
+ //~^ ERROR suffixes on a tuple index are invalid
+ println!("{}", b);
+ let c = (1, 2, 3);
+ let d = c.1suffix;
+ //~^ ERROR suffixes on a tuple index are invalid
+ println!("{}", d);
+ let s = X { 0suffix: 0, 1: 1, 2: 2 };
+ //~^ ERROR suffixes on a tuple index are invalid
+ match s {
+ X { 0suffix: _, .. } => {}
+ //~^ ERROR suffixes on a tuple index are invalid
+ }
+}
--- /dev/null
+error: suffixes on a tuple index are invalid
+ --> $DIR/issue-59418.rs:5:15
+ |
+LL | let b = a.1suffix;
+ | ^^^^^^^ invalid suffix `suffix`
+
+error: suffixes on a tuple index are invalid
+ --> $DIR/issue-59418.rs:9:15
+ |
+LL | let d = c.1suffix;
+ | ^^^^^^^ invalid suffix `suffix`
+
+error: suffixes on a tuple index are invalid
+ --> $DIR/issue-59418.rs:12:17
+ |
+LL | let s = X { 0suffix: 0, 1: 1, 2: 2 };
+ | ^^^^^^^ invalid suffix `suffix`
+
+error: suffixes on a tuple index are invalid
+ --> $DIR/issue-59418.rs:15:13
+ |
+LL | X { 0suffix: _, .. } => {}
+ | ^^^^^^^ invalid suffix `suffix`
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+fn main() {}
+
+trait T {
+ fn qux() -> Option<usize> {
+ let _ = if true {
+ });
+//~^ ERROR non-item in item list
+//~| ERROR mismatched closing delimiter: `)`
+//~| ERROR expected one of `.`, `;`
+ Some(4)
+ }
--- /dev/null
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}`
+ --> $DIR/issue-60075.rs:6:10
+ |
+LL | });
+ | ^ expected one of `.`, `;`, `?`, `else`, or an operator
+
+error: non-item in item list
+ --> $DIR/issue-60075.rs:6:11
+ |
+LL | trait T {
+ | - item list starts here
+...
+LL | });
+ | ^ non-item starts here
+...
+LL | }
+ | - item list ends here
+
+error: mismatched closing delimiter: `)`
+ --> $DIR/issue-60075.rs:4:31
+ |
+LL | fn qux() -> Option<usize> {
+ | ^ unclosed delimiter
+LL | let _ = if true {
+LL | });
+ | ^ mismatched closing delimiter
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// ignore-tidy-trailing-newlines
+// error-pattern: aborting due to 3 previous errors
+#![allow(uncommon_codepoints)]
+
+y![
+Ϥ,
\ No newline at end of file
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62524.rs:6:3
+ |
+LL | y![
+ | - unclosed delimiter
+LL | Ϥ,
+ | ^
+
+error: macros that expand to items must be delimited with braces or followed by a semicolon
+ --> $DIR/issue-62524.rs:5:3
+ |
+LL | y![
+ | ___^
+LL | | Ϥ,
+ | |__^
+ |
+help: change the delimiters to curly braces
+ |
+LL | y! { /* items */ }
+ | ~~~~~~~~~~~~~~~
+help: add a semicolon
+ |
+LL | Ϥ,;
+ | +
+
+error: cannot find macro `y` in this scope
+ --> $DIR/issue-62524.rs:5:1
+ |
+LL | y![
+ | ^
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+pub t(#
+//~^ ERROR missing `fn` or `struct` for function or struct definition
+//~ ERROR this file contains an unclosed delimiter
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62546.rs:3:52
+ |
+LL | pub t(#
+ | - unclosed delimiter
+LL |
+LL |
+ | ^
+
+error: missing `fn` or `struct` for function or struct definition
+ --> $DIR/issue-62546.rs:1:4
+ |
+LL | pub t(#
+ | ---^- help: if you meant to call a macro, try: `t!`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// error-pattern:this file contains an unclosed delimiter
+// error-pattern:xpected `{`, found `macro_rules`
+
+fn main() {}
+
+fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62554.rs:6:89
+ |
+LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+ | - - - - - ^
+ | | | | | |
+ | | | | | unclosed delimiter
+ | | | | unclosed delimiter
+ | | | unclosed delimiter
+ | unclosed delimiter unclosed delimiter
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62554.rs:6:89
+ |
+LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+ | - - - - - ^
+ | | | | | |
+ | | | | | unclosed delimiter
+ | | | | unclosed delimiter
+ | | | unclosed delimiter
+ | unclosed delimiter unclosed delimiter
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62554.rs:6:89
+ |
+LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+ | - - - - - ^
+ | | | | | |
+ | | | | | unclosed delimiter
+ | | | | unclosed delimiter
+ | | | unclosed delimiter
+ | unclosed delimiter unclosed delimiter
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62554.rs:6:89
+ |
+LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+ | - - - - - ^
+ | | | | | |
+ | | | | | unclosed delimiter
+ | | | | unclosed delimiter
+ | | | unclosed delimiter
+ | unclosed delimiter unclosed delimiter
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62554.rs:6:89
+ |
+LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+ | - - - - - ^
+ | | | | | |
+ | | | | | unclosed delimiter
+ | | | | unclosed delimiter
+ | | | unclosed delimiter
+ | unclosed delimiter unclosed delimiter
+
+error: expected `{`, found `macro_rules`
+ --> $DIR/issue-62554.rs:6:23
+ |
+LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+ | -- ^^^^^^^^^^^ expected `{`
+ | |
+ | this `if` expression has a condition, but no block
+ |
+help: try placing this code inside a block
+ |
+LL ~ fn foo(u: u8) { if u8 { macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 {
+LL + }
+ |
+
+error: aborting due to 6 previous errors
+
--- /dev/null
+// Regression test for issue #62660: if a receiver's type does not
+// successfully parse, emit the correct error instead of ICE-ing the compiler.
+
+struct Foo;
+
+impl Foo {
+ pub fn foo(_: i32, self: Box<Self) {}
+ //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)`
+}
+
+fn main() {}
--- /dev/null
+error: expected one of `!`, `(`, `+`, `,`, `::`, `:`, `<`, `=`, or `>`, found `)`
+ --> $DIR/issue-62660.rs:7:38
+ |
+LL | pub fn foo(_: i32, self: Box<Self) {}
+ | ^ expected one of 9 possible tokens
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {}
+
+fn f() -> isize { fn f() -> isize {} pub f<
+//~^ ERROR missing `fn` or `struct` for function or struct definition
+//~| ERROR mismatched types
+//~ ERROR this file contains an unclosed delimiter
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62881.rs:6:52
+ |
+LL | fn f() -> isize { fn f() -> isize {} pub f<
+ | - unclosed delimiter
+...
+LL |
+ | ^
+
+error: missing `fn` or `struct` for function or struct definition
+ --> $DIR/issue-62881.rs:3:41
+ |
+LL | fn f() -> isize { fn f() -> isize {} pub f<
+ | ^
+
+error[E0308]: mismatched types
+ --> $DIR/issue-62881.rs:3:29
+ |
+LL | fn f() -> isize { fn f() -> isize {} pub f<
+ | - ^^^^^ expected `isize`, found `()`
+ | |
+ | implicitly returns `()` as its body has no tail or `return` expression
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// Regression test for #62894, shouldn't crash.
+// error-pattern: this file contains an unclosed delimiter
+// error-pattern: expected one of `(`, `[`, or `{`, found keyword `fn`
+
+fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
+
+fn main() {}
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62894.rs:7:14
+ |
+LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
+ | - - - unclosed delimiter
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+LL |
+LL | fn main() {}
+ | ^
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62894.rs:7:14
+ |
+LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
+ | - - - unclosed delimiter
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+LL |
+LL | fn main() {}
+ | ^
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62894.rs:7:14
+ |
+LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
+ | - - - unclosed delimiter
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+LL |
+LL | fn main() {}
+ | ^
+
+error: expected one of `(`, `[`, or `{`, found keyword `fn`
+ --> $DIR/issue-62894.rs:7:1
+ |
+LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq!
+ | - expected one of `(`, `[`, or `{`
+LL |
+LL | fn main() {}
+ | ^^ unexpected token
+ |
+ ::: $SRC_DIR/core/src/macros/mod.rs:LL:COL
+ |
+LL | ($left:expr, $right:expr $(,)?) => ({
+ | ---------- while parsing argument for this `expr` macro fragment
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+fn main() {}
+
+fn v() -> isize { //~ ERROR mismatched types
+mod _ { //~ ERROR expected identifier
+pub fn g() -> isizee { //~ ERROR cannot find type `isizee` in this scope
+mod _ { //~ ERROR expected identifier
+pub g() -> is //~ ERROR missing `fn` for function definition
+(), w20);
+}
+(), w20); //~ ERROR expected item, found `;`
+}
--- /dev/null
+error: expected identifier, found reserved identifier `_`
+ --> $DIR/issue-62895.rs:4:5
+ |
+LL | mod _ {
+ | ^ expected identifier, found reserved identifier
+
+error: expected identifier, found reserved identifier `_`
+ --> $DIR/issue-62895.rs:6:5
+ |
+LL | mod _ {
+ | ^ expected identifier, found reserved identifier
+
+error: missing `fn` for function definition
+ --> $DIR/issue-62895.rs:7:4
+ |
+LL | pub g() -> is
+ | ^^^^
+ |
+help: add `fn` here to parse `g` as a public function
+ |
+LL | pub fn g() -> is
+ | ++
+
+error: expected item, found `;`
+ --> $DIR/issue-62895.rs:10:9
+ |
+LL | (), w20);
+ | ^ help: remove this semicolon
+
+error[E0412]: cannot find type `isizee` in this scope
+ --> $DIR/issue-62895.rs:5:15
+ |
+LL | pub fn g() -> isizee {
+ | ^^^^^^ help: a builtin type with a similar name exists: `isize`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-62895.rs:3:11
+ |
+LL | fn v() -> isize {
+ | - ^^^^^ expected `isize`, found `()`
+ | |
+ | implicitly returns `()` as its body has no tail or `return` expression
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0308, E0412.
+For more information about an error, try `rustc --explain E0308`.
--- /dev/null
+"\u\\"
+//~^ ERROR incorrect unicode escape sequence
+//~| ERROR invalid trailing slash in literal
+//~| ERROR expected item, found `"\u\\"`
--- /dev/null
+error: incorrect unicode escape sequence
+ --> $DIR/issue-62913.rs:1:2
+ |
+LL | "\u\"
+ | ^^^ incorrect unicode escape sequence
+ |
+ = help: format of unicode escape sequences is `\u{...}`
+
+error: invalid trailing slash in literal
+ --> $DIR/issue-62913.rs:1:5
+ |
+LL | "\u\"
+ | ^ invalid trailing slash in literal
+
+error: expected item, found `"\u\"`
+ --> $DIR/issue-62913.rs:1:1
+ |
+LL | "\u\"
+ | ^^^^^^ expected item
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// ignore-tidy-trailing-newlines
+// error-pattern: aborting due to 7 previous errors
+
+fn main() {}
+
+fn p() { match s { v, E { [) {) }
+
+
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62973.rs:8:2
+ |
+LL | fn p() { match s { v, E { [) {) }
+ | - - unclosed delimiter
+ | |
+ | unclosed delimiter
+LL |
+LL |
+ | ^
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-62973.rs:8:2
+ |
+LL | fn p() { match s { v, E { [) {) }
+ | - - unclosed delimiter
+ | |
+ | unclosed delimiter
+LL |
+LL |
+ | ^
+
+error: expected one of `,` or `}`, found `{`
+ --> $DIR/issue-62973.rs:6:8
+ |
+LL | fn p() { match s { v, E { [) {) }
+ | ^ - -^ expected one of `,` or `}`
+ | | | |
+ | | | help: `}` may belong here
+ | | while parsing this struct
+ | unclosed delimiter
+
+error: struct literals are not allowed here
+ --> $DIR/issue-62973.rs:6:16
+ |
+LL | fn p() { match s { v, E { [) {) }
+ | ________________^
+LL | |
+LL | |
+ | |_^
+ |
+help: surround the struct literal with parentheses
+ |
+LL ~ fn p() { match (s { v, E { [) {) }
+LL |
+LL ~ )
+ |
+
+error: expected one of `.`, `?`, `{`, or an operator, found `}`
+ --> $DIR/issue-62973.rs:8:2
+ |
+LL | fn p() { match s { v, E { [) {) }
+ | ----- while parsing this match expression
+LL |
+LL |
+ | ^ expected one of `.`, `?`, `{`, or an operator
+
+error: mismatched closing delimiter: `)`
+ --> $DIR/issue-62973.rs:6:27
+ |
+LL | fn p() { match s { v, E { [) {) }
+ | ^^ mismatched closing delimiter
+ | |
+ | unclosed delimiter
+
+error: mismatched closing delimiter: `)`
+ --> $DIR/issue-62973.rs:6:30
+ |
+LL | fn p() { match s { v, E { [) {) }
+ | ^^ mismatched closing delimiter
+ | |
+ | unclosed delimiter
+
+error: aborting due to 7 previous errors
+
--- /dev/null
+// check-pass
+
+#![feature(exclusive_range_pattern)]
+#![feature(half_open_range_patterns)]
+
+#![allow(ellipsis_inclusive_range_patterns)]
+
+fn main() {
+ macro_rules! mac_expr {
+ ($e:expr) => {
+ if let 2...$e = 3 {}
+ if let 2..=$e = 3 {}
+ if let 2..$e = 3 {}
+ if let ..$e = 3 {}
+ if let ..=$e = 3 {}
+ if let $e.. = 5 {}
+ if let $e..5 = 4 {}
+ if let $e..=5 = 4 {}
+ }
+ }
+ mac_expr!(4);
+}
--- /dev/null
+// fixed by #66361
+// error-pattern: aborting due to 3 previous errors
+impl W <s(f;Y(;]
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-63116.rs:3:18
+ |
+LL | impl W <s(f;Y(;]
+ | - ^
+ | |
+ | unclosed delimiter
+
+error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;`
+ --> $DIR/issue-63116.rs:3:12
+ |
+LL | impl W <s(f;Y(;]
+ | ^ expected one of 7 possible tokens
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-63116.rs:3:14
+ |
+LL | impl W <s(f;Y(;]
+ | ^ ^ mismatched closing delimiter
+ | |
+ | unclosed delimiter
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// error-pattern: aborting due to 5 previous errors
+
+fn i(n{...,f #
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-63135.rs:3:16
+ |
+LL | fn i(n{...,f #
+ | - - ^
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-63135.rs:3:16
+ |
+LL | fn i(n{...,f #
+ | - - ^
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+
+error: expected field pattern, found `...`
+ --> $DIR/issue-63135.rs:3:8
+ |
+LL | fn i(n{...,f #
+ | ^^^ help: to omit remaining fields, use one fewer `.`: `..`
+
+error: expected `}`, found `,`
+ --> $DIR/issue-63135.rs:3:11
+ |
+LL | fn i(n{...,f #
+ | ---^
+ | | |
+ | | expected `}`
+ | `..` must be at the end and cannot have a trailing comma
+
+error: expected one of `!` or `[`, found `}`
+ --> $DIR/issue-63135.rs:3:16
+ |
+LL | fn i(n{...,f #
+ | - ^ expected one of `!` or `[`
+ | |
+ | while parsing the fields for this pattern
+
+error: aborting due to 5 previous errors
+
--- /dev/null
+#![allow(unused)]
+fn main() {
+ let _foo = b'hello\0';
+ //~^ ERROR character literal may only contain one codepoint
+ //~| HELP if you meant to write a byte string literal, use double quotes
+ let _bar = 'hello';
+ //~^ ERROR character literal may only contain one codepoint
+ //~| HELP if you meant to write a `str` literal, use double quotes
+}
--- /dev/null
+error: character literal may only contain one codepoint
+ --> $DIR/issue-64732.rs:3:16
+ |
+LL | let _foo = b'hello\0';
+ | ^^^^^^^^^^
+ |
+help: if you meant to write a byte string literal, use double quotes
+ |
+LL | let _foo = b"hello\0";
+ | ~~~~~~~~~~
+
+error: character literal may only contain one codepoint
+ --> $DIR/issue-64732.rs:6:16
+ |
+LL | let _bar = 'hello';
+ | ^^^^^^^
+ |
+help: if you meant to write a `str` literal, use double quotes
+ |
+LL | let _bar = "hello";
+ | ~~~~~~~
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// check-pass
+
+// Here we check that a `:vis` macro matcher subsititued for the empty visibility
+// (`VisibilityKind::Inherited`) is accepted when used before an enum variant.
+
+fn main() {}
+
+macro_rules! mac_variant {
+ ($vis:vis MARKER) => {
+ enum Enum {
+ $vis Unit,
+
+ $vis Tuple(u8, u16),
+
+ $vis Struct { f: u8 },
+ }
+ }
+}
+
+mac_variant!(MARKER);
+
+// We also accept visibilities on variants syntactically but not semantically.
+#[cfg(FALSE)]
+enum E {
+ pub U,
+ pub(crate) T(u8),
+ pub(super) T { f: String }
+}
--- /dev/null
+// check-pass
+
+// Here we check that a `:vis` macro matcher subsititued for the empty visibility
+// (`VisibilityKind::Inherited`) is accepted when used before an item in a trait.
+
+fn main() {}
+
+macro_rules! mac_in_trait {
+ ($vis:vis MARKER) => {
+ $vis fn beta() {}
+
+ $vis const GAMMA: u8;
+
+ $vis type Delta;
+ }
+}
+
+trait Alpha {
+ mac_in_trait!(MARKER);
+}
+
+// We also accept visibilities on items in traits syntactically but not semantically.
+#[cfg(FALSE)]
+trait Foo {
+ pub fn bar();
+ pub(crate) type baz;
+ pub(super) const QUUX: u8;
+}
--- /dev/null
+// Regression test; used to ICE with 'visit_mac_call disabled by default' due to a
+// `MutVisitor` in `fn make_all_value_bindings_mutable` (`parse/parser/pat.rs`).
+
+macro_rules! mac1 {
+ ($eval:expr) => {
+ let mut $eval = ();
+ //~^ ERROR `mut` must be followed by a named binding
+ };
+}
+
+macro_rules! mac2 {
+ ($eval:pat) => {
+ let mut $eval = ();
+ //~^ ERROR `mut` must be followed by a named binding
+ //~| ERROR expected identifier, found `does_not_exist!()`
+ };
+}
+
+fn foo() {
+ mac1! { does_not_exist!() }
+ //~^ ERROR cannot find macro `does_not_exist` in this scope
+ mac2! { does_not_exist!() }
+ //~^ ERROR cannot find macro `does_not_exist` in this scope
+}
+
+fn main() {}
--- /dev/null
+error: `mut` must be followed by a named binding
+ --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:6:13
+ |
+LL | let mut $eval = ();
+ | ^^^^^^^^^ help: remove the `mut` prefix: `does_not_exist!()`
+...
+LL | mac1! { does_not_exist!() }
+ | --------------------------- in this macro invocation
+ |
+ = note: `mut` may be followed by `variable` and `variable @ pattern`
+ = note: this error originates in the macro `mac1` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: expected identifier, found `does_not_exist!()`
+ --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:17
+ |
+LL | let mut $eval = ();
+ | ^^^^^ expected identifier
+...
+LL | mac2! { does_not_exist!() }
+ | --------------------------- in this macro invocation
+ |
+ = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: `mut` must be followed by a named binding
+ --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:13
+ |
+LL | let mut $eval = ();
+ | ^^^ help: remove the `mut` prefix: `does_not_exist!()`
+...
+LL | mac2! { does_not_exist!() }
+ | --------------------------- in this macro invocation
+ |
+ = note: `mut` may be followed by `variable` and `variable @ pattern`
+ = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: cannot find macro `does_not_exist` in this scope
+ --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:22:13
+ |
+LL | mac2! { does_not_exist!() }
+ | ^^^^^^^^^^^^^^
+
+error: cannot find macro `does_not_exist` in this scope
+ --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:20:13
+ |
+LL | mac1! { does_not_exist!() }
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
+
--- /dev/null
+fn main() {
+ auto n = 0;//~ ERROR invalid variable declaration
+ //~^ HELP write `let` instead of `auto` to introduce a new variable
+ auto m;//~ ERROR invalid variable declaration
+ //~^ HELP write `let` instead of `auto` to introduce a new variable
+ m = 0;
+
+ var n = 0;//~ ERROR invalid variable declaration
+ //~^ HELP write `let` instead of `var` to introduce a new variable
+ var m;//~ ERROR invalid variable declaration
+ //~^ HELP write `let` instead of `var` to introduce a new variable
+ m = 0;
+
+ mut n = 0;//~ ERROR invalid variable declaration
+ //~^ HELP missing keyword
+ mut var;//~ ERROR invalid variable declaration
+ //~^ HELP missing keyword
+ var = 0;
+
+ let _recovery_witness: () = 0; //~ ERROR mismatched types
+}
--- /dev/null
+error: invalid variable declaration
+ --> $DIR/issue-65257-invalid-var-decl-recovery.rs:2:5
+ |
+LL | auto n = 0;
+ | ^^^^
+ |
+help: write `let` instead of `auto` to introduce a new variable
+ |
+LL | let n = 0;
+ | ~~~
+
+error: invalid variable declaration
+ --> $DIR/issue-65257-invalid-var-decl-recovery.rs:4:5
+ |
+LL | auto m;
+ | ^^^^
+ |
+help: write `let` instead of `auto` to introduce a new variable
+ |
+LL | let m;
+ | ~~~
+
+error: invalid variable declaration
+ --> $DIR/issue-65257-invalid-var-decl-recovery.rs:8:5
+ |
+LL | var n = 0;
+ | ^^^
+ |
+help: write `let` instead of `var` to introduce a new variable
+ |
+LL | let n = 0;
+ | ~~~
+
+error: invalid variable declaration
+ --> $DIR/issue-65257-invalid-var-decl-recovery.rs:10:5
+ |
+LL | var m;
+ | ^^^
+ |
+help: write `let` instead of `var` to introduce a new variable
+ |
+LL | let m;
+ | ~~~
+
+error: invalid variable declaration
+ --> $DIR/issue-65257-invalid-var-decl-recovery.rs:14:5
+ |
+LL | mut n = 0;
+ | ^^^ help: missing keyword: `let mut`
+
+error: invalid variable declaration
+ --> $DIR/issue-65257-invalid-var-decl-recovery.rs:16:5
+ |
+LL | mut var;
+ | ^^^ help: missing keyword: `let mut`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-65257-invalid-var-decl-recovery.rs:20:33
+ |
+LL | let _recovery_witness: () = 0;
+ | -- ^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// run-pass
+
+// Test that failing macro matchers will not cause pre-expansion errors
+// even though they use a feature that is pre-expansion gated.
+
+macro_rules! m {
+ ($e:expr) => { 0 }; // This fails on the input below due to `, foo`.
+ ($e:expr,) => { 1 }; // This also fails to match due to `foo`.
+ (box $e:expr, foo) => { 2 }; // Successful matcher, we should get `2`.
+}
+
+fn main() {
+ assert_eq!(2, m!(box 42, foo));
+}
--- /dev/null
+trait Foo { fn a() } //~ ERROR expected one of `->`, `;`, `where`, or `{`, found `}`
+
+fn main() {}
--- /dev/null
+error: expected one of `->`, `;`, `where`, or `{`, found `}`
+ --> $DIR/issue-6610.rs:1:20
+ |
+LL | trait Foo { fn a() }
+ | - ^ expected one of `->`, `;`, `where`, or `{`
+ | |
+ | while parsing this `fn`
+
+error: aborting due to previous error
+
--- /dev/null
+// The problem in #66357 was that the call trace:
+//
+// - parse_fn_block_decl
+// - expect_or
+// - unexpected
+// - expect_one_of
+// - expected_one_of_not_found
+// - recover_closing_delimiter
+//
+// ended up bubbling up `Ok(true)` to `unexpected` which then used `unreachable!()`.
+
+fn f() { |[](* }
+//~^ ERROR expected one of `,` or `:`, found `(`
+//~| ERROR expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*`
--- /dev/null
+error: expected one of `,` or `:`, found `(`
+ --> $DIR/issue-66357-unexpected-unreachable.rs:12:13
+ |
+LL | fn f() { |[](* }
+ | ^ expected one of `,` or `:`
+
+error: expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*`
+ --> $DIR/issue-66357-unexpected-unreachable.rs:12:13
+ |
+LL | fn f() { |[](* }
+ | ^^ help: `)` may belong here
+ | |
+ | unclosed delimiter
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// run-rustfix
+
+// In this regression test for #67146, we check that the
+// negative outlives bound `!'a` is rejected by the parser.
+// This regression was first introduced in PR #57364.
+
+fn main() {}
+
+pub fn f1<T>() {}
+//~^ ERROR negative bounds are not supported
+pub fn f2<'a, T: Ord>() {}
+//~^ ERROR negative bounds are not supported
+pub fn f3<'a, T: Ord>() {}
+//~^ ERROR negative bounds are not supported
--- /dev/null
+// run-rustfix
+
+// In this regression test for #67146, we check that the
+// negative outlives bound `!'a` is rejected by the parser.
+// This regression was first introduced in PR #57364.
+
+fn main() {}
+
+pub fn f1<T: !'static>() {}
+//~^ ERROR negative bounds are not supported
+pub fn f2<'a, T: Ord + !'a>() {}
+//~^ ERROR negative bounds are not supported
+pub fn f3<'a, T: !'a + Ord>() {}
+//~^ ERROR negative bounds are not supported
--- /dev/null
+error: negative bounds are not supported
+ --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:12
+ |
+LL | pub fn f1<T: !'static>() {}
+ | ^^^^^^^^^^ negative bounds are not supported
+
+error: negative bounds are not supported
+ --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:11:22
+ |
+LL | pub fn f2<'a, T: Ord + !'a>() {}
+ | ^^^^^ negative bounds are not supported
+
+error: negative bounds are not supported
+ --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:13:16
+ |
+LL | pub fn f3<'a, T: !'a + Ord>() {}
+ | ^^^^^ negative bounds are not supported
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+mod a {
+ use std::marker::PhantomData;
+
+ enum Bug {
+ V = [PhantomData; { [ () ].len() ].len() as isize,
+ //~^ ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ }
+}
+
+mod b {
+ enum Bug {
+ V = [Vec::new; { [].len() ].len() as isize,
+ //~^ ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR type annotations needed
+ }
+}
+
+mod c {
+ enum Bug {
+ V = [Vec::new; { [0].len() ].len() as isize,
+ //~^ ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR mismatched closing delimiter: `]`
+ //~| ERROR type annotations needed
+ }
+}
+
+fn main() {}
--- /dev/null
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
+ |
+LL | V = [PhantomData; { [ () ].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
+ |
+LL | V = [Vec::new; { [].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
+ |
+LL | V = [Vec::new; { [0].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
+ |
+LL | V = [PhantomData; { [ () ].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
+ |
+LL | V = [Vec::new; { [].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
+ |
+LL | V = [Vec::new; { [0].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
+ |
+LL | V = [PhantomData; { [ () ].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
+ |
+LL | V = [Vec::new; { [].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
+ |
+LL | V = [Vec::new; { [0].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27
+ |
+LL | V = [PhantomData; { [ () ].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24
+ |
+LL | V = [Vec::new; { [].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error: mismatched closing delimiter: `]`
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24
+ |
+LL | V = [Vec::new; { [0].len() ].len() as isize,
+ | - ^ ^ mismatched closing delimiter
+ | | |
+ | | unclosed delimiter
+ | closing delimiter possibly meant for this
+
+error[E0282]: type annotations needed
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:29
+ |
+LL | V = [Vec::new; { [].len() ].len() as isize,
+ | ^^^ cannot infer type for type parameter `T`
+
+error[E0282]: type annotations needed
+ --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:14
+ |
+LL | V = [Vec::new; { [0].len() ].len() as isize,
+ | ^^^^^^^^ cannot infer type for type parameter `T`
+
+error: aborting due to 14 previous errors
+
+For more information about this error, try `rustc --explain E0282`.
--- /dev/null
+pub struct Foo {
+ pub bar: Vec<i32>ö
+ //~^ ERROR expected `,`, or `}`, found `ö`
+} //~ ERROR expected `:`, found `}`
+
+fn main() {}
--- /dev/null
+error: expected `,`, or `}`, found `ö`
+ --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:2:22
+ |
+LL | pub bar: Vec<i32>ö
+ | ^ help: try adding a comma: `,`
+
+error: expected `:`, found `}`
+ --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:4:1
+ |
+LL | pub bar: Vec<i32>ö
+ | - expected `:`
+LL |
+LL | }
+ | ^ unexpected token
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+// Make sure we don't propagate restrictions on trait impl items to items inside them.
+
+// check-pass
+// edition:2018
+
+fn main() {}
+
+trait X {
+ fn foo();
+}
+
+impl X for () {
+ fn foo() {
+ struct S;
+ impl S {
+ pub const X: u8 = 0;
+ pub const fn bar() {}
+ async fn qux() {}
+ }
+ }
+}
--- /dev/null
+fn main() {}
+
+type X<'a> = (?'a) +;
+//~^ ERROR `?` may only modify trait bounds, not lifetime bounds
+//~| ERROR at least one trait is required for an object type
+//~| WARN trait objects without an explicit `dyn` are deprecated
+//~| WARN this is accepted in the current edition
--- /dev/null
+error: `?` may only modify trait bounds, not lifetime bounds
+ --> $DIR/issue-68890-2.rs:3:15
+ |
+LL | type X<'a> = (?'a) +;
+ | ^
+
+warning: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/issue-68890-2.rs:3:14
+ |
+LL | type X<'a> = (?'a) +;
+ | ^^^^^^^ help: use `dyn`: `dyn (?'a) +`
+ |
+ = note: `#[warn(bare_trait_objects)]` on by default
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+
+error[E0224]: at least one trait is required for an object type
+ --> $DIR/issue-68890-2.rs:3:14
+ |
+LL | type X<'a> = (?'a) +;
+ | ^^^^^^^
+
+error: aborting due to 2 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0224`.
--- /dev/null
+enum e{A((?'a a+?+l))}
+//~^ ERROR `?` may only modify trait bounds, not lifetime bounds
+//~| ERROR expected one of `)`, `+`, or `,`
+//~| ERROR expected item, found `)`
--- /dev/null
+error: `?` may only modify trait bounds, not lifetime bounds
+ --> $DIR/issue-68890.rs:1:11
+ |
+LL | enum e{A((?'a a+?+l))}
+ | ^
+
+error: expected one of `)`, `+`, or `,`, found `a`
+ --> $DIR/issue-68890.rs:1:15
+ |
+LL | enum e{A((?'a a+?+l))}
+ | ^ expected one of `)`, `+`, or `,`
+
+error: expected item, found `)`
+ --> $DIR/issue-68890.rs:1:21
+ |
+LL | enum e{A((?'a a+?+l))}
+ | ^ expected item
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// check-pass
+
+macro_rules! foo {
+ ($a:literal) => {
+ bar!($a)
+ };
+}
+
+macro_rules! bar {
+ ($b:literal) => {};
+}
+
+fn main() {
+ foo!(-2);
+ bar!(-2);
+}
--- /dev/null
+struct Foo(i32);
+
+fn main() {
+ let Foo(...) = Foo(0); //~ ERROR unexpected `...`
+ let [_, ..., _] = [0, 1]; //~ ERROR unexpected `...`
+ let _recovery_witness: () = 0; //~ ERROR mismatched types
+}
--- /dev/null
+error: unexpected `...`
+ --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:4:13
+ |
+LL | let Foo(...) = Foo(0);
+ | ^^^
+ | |
+ | not a valid pattern
+ | help: for a rest pattern, use `..` instead of `...`
+
+error: unexpected `...`
+ --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:5:13
+ |
+LL | let [_, ..., _] = [0, 1];
+ | ^^^
+ | |
+ | not a valid pattern
+ | help: for a rest pattern, use `..` instead of `...`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:6:33
+ |
+LL | let _recovery_witness: () = 0;
+ | -- ^ expected `()`, found integer
+ | |
+ | expected due to this
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// run-rustfix
+// This is for checking if we can apply suggestions as-is.
+
+pub struct Foo(i32);
+
+fn main() {
+ let Foo(..) = Foo(0); //~ ERROR unexpected `...`
+ let [_, .., _] = [0, 1]; //~ ERROR unexpected `...`
+}
--- /dev/null
+// run-rustfix
+// This is for checking if we can apply suggestions as-is.
+
+pub struct Foo(i32);
+
+fn main() {
+ let Foo(...) = Foo(0); //~ ERROR unexpected `...`
+ let [_, ..., _] = [0, 1]; //~ ERROR unexpected `...`
+}
--- /dev/null
+error: unexpected `...`
+ --> $DIR/issue-70388-without-witness.rs:7:13
+ |
+LL | let Foo(...) = Foo(0);
+ | ^^^
+ | |
+ | not a valid pattern
+ | help: for a rest pattern, use `..` instead of `...`
+
+error: unexpected `...`
+ --> $DIR/issue-70388-without-witness.rs:8:13
+ |
+LL | let [_, ..., _] = [0, 1];
+ | ^^^
+ | |
+ | not a valid pattern
+ | help: for a rest pattern, use `..` instead of `...`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+struct S {}
+
+impl S {
+ fn foo(&mur Self) {}
+ //~^ ERROR expected identifier, found keyword `Self`
+ //~| ERROR expected one of `:`, `@`
+ //~| ERROR the `Self` constructor can only be used with
+ fn bar(&'static mur Self) {}
+ //~^ ERROR unexpected lifetime
+ //~| ERROR expected identifier, found keyword `Self`
+ //~| ERROR expected one of `:`, `@`
+ //~| ERROR the `Self` constructor can only be used with
+
+ fn baz(&mur Self @ _) {}
+ //~^ ERROR expected one of `:`, `@`
+}
+
+fn main() {}
--- /dev/null
+error: expected identifier, found keyword `Self`
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17
+ |
+LL | fn foo(&mur Self) {}
+ | ^^^^ expected identifier, found keyword
+
+error: expected one of `:`, `@`, or `|`, found keyword `Self`
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17
+ |
+LL | fn foo(&mur Self) {}
+ | -----^^^^
+ | | |
+ | | expected one of `:`, `@`, or `|`
+ | help: declare the type after the parameter binding: `<identifier>: <type>`
+
+error: unexpected lifetime `'static` in pattern
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:13
+ |
+LL | fn bar(&'static mur Self) {}
+ | ^^^^^^^ help: remove the lifetime
+
+error: expected identifier, found keyword `Self`
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25
+ |
+LL | fn bar(&'static mur Self) {}
+ | ^^^^ expected identifier, found keyword
+
+error: expected one of `:`, `@`, or `|`, found keyword `Self`
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25
+ |
+LL | fn bar(&'static mur Self) {}
+ | -------------^^^^
+ | | |
+ | | expected one of `:`, `@`, or `|`
+ | help: declare the type after the parameter binding: `<identifier>: <type>`
+
+error: expected one of `:`, `@`, or `|`, found keyword `Self`
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:14:17
+ |
+LL | fn baz(&mur Self @ _) {}
+ | ^^^^ expected one of `:`, `@`, or `|`
+
+error: the `Self` constructor can only be used with tuple or unit structs
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17
+ |
+LL | fn foo(&mur Self) {}
+ | ^^^^ help: use curly brackets: `Self { /* fields */ }`
+
+error: the `Self` constructor can only be used with tuple or unit structs
+ --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25
+ |
+LL | fn bar(&'static mur Self) {}
+ | ^^^^ help: use curly brackets: `Self { /* fields */ }`
+
+error: aborting due to 8 previous errors
+
--- /dev/null
+fn main() {
+ expr as fun()(:); //~ ERROR expected expression
+}
--- /dev/null
+error: expected expression, found `:`
+ --> $DIR/issue-70552-ascription-in-parens-after-call.rs:2:19
+ |
+LL | expr as fun()(:);
+ | ^ expected expression
+
+error: aborting due to previous error
+
--- /dev/null
+pub enum ErrorHandled {
+ Reported,
+ TooGeneric,
+}
+
+impl ErrorHandled {
+ pub fn assert_reported(self) {
+ match self {
+ ErrorHandled::Reported => {}
+ ErrorHandled::TooGeneric => panic!(),
+ }
+ }
+}
+
+fn struct_generic(x: Vec<i32>) {
+ for v in x {
+ println!("{}", v);
+ }
+ }
+} //~ ERROR unexpected closing delimiter: `}`
--- /dev/null
+error: unexpected closing delimiter: `}`
+ --> $DIR/issue-70583-block-is-empty-1.rs:20:1
+ |
+LL | fn struct_generic(x: Vec<i32>) {
+ | - this opening brace...
+...
+LL | }
+ | - ...matches this closing brace
+LL | }
+ | ^ unexpected closing delimiter
+
+error: aborting due to previous error
+
--- /dev/null
+pub enum ErrorHandled {
+ Reported,
+ TooGeneric,
+}
+
+impl ErrorHandled {
+ pub fn assert_reported(self) {
+ match self {
+ ErrorHandled::Reported => {}}
+ //^~ ERROR block is empty, you might have not meant to close it
+ ErrorHandled::TooGeneric => panic!(),
+ }
+ }
+} //~ ERROR unexpected closing delimiter: `}`
--- /dev/null
+error: unexpected closing delimiter: `}`
+ --> $DIR/issue-70583-block-is-empty-2.rs:14:1
+ |
+LL | ErrorHandled::Reported => {}}
+ | -- block is empty, you might have not meant to close it
+...
+LL | }
+ | ^ unexpected closing delimiter
+
+error: aborting due to previous error
+
--- /dev/null
+// run-pass
+// pretty-expanded FIXME #23616
+#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620
+
+pub fn main() {
+ const FOO: f64 = 10.0;
+
+ match 0.0 {
+ 0.0 ..= FOO => (),
+ _ => ()
+ }
+}
--- /dev/null
+fn main() {
+ let a = std::process::Command::new("echo")
+ .arg("1")
+ ,arg("2") //~ ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `,`
+ .output();
+}
--- /dev/null
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `,`
+ --> $DIR/issue-72253.rs:4:9
+ |
+LL | .arg("1")
+ | - expected one of `.`, `;`, `?`, `else`, or an operator
+LL | ,arg("2")
+ | ^ unexpected token
+
+error: aborting due to previous error
+
--- /dev/null
+fn foo(c: &[u32], n: u32) -> u32 {
+ match *c {
+ [h, ..] if h > n => 0,
+ [h, ..] if h == n => 1,
+ [h, ref ts..] => foo(c, n - h) + foo(ts, n),
+ //~^ ERROR expected one of `,`, `@`, `]`, or `|`, found `..`
+ [] => 0,
+ }
+}
--- /dev/null
+error: expected one of `,`, `@`, `]`, or `|`, found `..`
+ --> $DIR/issue-72373.rs:5:19
+ |
+LL | [h, ref ts..] => foo(c, n - h) + foo(ts, n),
+ | ^^ expected one of `,`, `@`, `]`, or `|`
+ |
+help: if you meant to bind the contents of the rest of the array pattern into `ts`, use `@`
+ |
+LL | [h, ref ts @ ..] => foo(c, n - h) + foo(ts, n),
+ | +
+
+error: aborting due to previous error
+
--- /dev/null
+#![crate_type="lib"]
+fn x<'a>(x: &mut 'a i32){} //~ ERROR lifetime must precede `mut`
+
+macro_rules! mac {
+ ($lt:lifetime) => {
+ fn w<$lt>(w: &mut $lt i32) {}
+ //~^ ERROR lifetime must precede `mut`
+ }
+}
+
+mac!('a);
+
+// avoid false positives
+fn y<'a>(y: &mut 'a + Send) {
+ //~^ ERROR expected a path on the left-hand side of `+`, not `&mut 'a`
+ //~| WARNING trait objects without an explicit `dyn` are deprecated
+ //~| WARN this is accepted in the current edition
+ //~| ERROR at least one trait is required for an object type
+ let z = y as &mut 'a + Send;
+ //~^ ERROR expected value, found trait `Send`
+ //~| WARNING trait objects without an explicit `dyn` are deprecated
+ //~| WARN this is accepted in the current edition
+}
--- /dev/null
+error: lifetime must precede `mut`
+ --> $DIR/issue-73568-lifetime-after-mut.rs:2:13
+ |
+LL | fn x<'a>(x: &mut 'a i32){}
+ | ^^^^^^^ help: place the lifetime before `mut`: `&'a mut`
+
+error[E0178]: expected a path on the left-hand side of `+`, not `&mut 'a`
+ --> $DIR/issue-73568-lifetime-after-mut.rs:14:13
+ |
+LL | fn y<'a>(y: &mut 'a + Send) {
+ | ^^^^^^^^^^^^^^ help: try adding parentheses: `&mut ('a + Send)`
+
+error: lifetime must precede `mut`
+ --> $DIR/issue-73568-lifetime-after-mut.rs:6:22
+ |
+LL | fn w<$lt>(w: &mut $lt i32) {}
+ | ^^^^^^^^ help: place the lifetime before `mut`: `&$lt mut`
+...
+LL | mac!('a);
+ | -------- in this macro invocation
+ |
+ = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0423]: expected value, found trait `Send`
+ --> $DIR/issue-73568-lifetime-after-mut.rs:19:28
+ |
+LL | let z = y as &mut 'a + Send;
+ | ^^^^ not a value
+
+warning: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/issue-73568-lifetime-after-mut.rs:14:18
+ |
+LL | fn y<'a>(y: &mut 'a + Send) {
+ | ^^ help: use `dyn`: `dyn 'a`
+ |
+ = note: `#[warn(bare_trait_objects)]` on by default
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+
+warning: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/issue-73568-lifetime-after-mut.rs:19:23
+ |
+LL | let z = y as &mut 'a + Send;
+ | ^^ help: use `dyn`: `dyn 'a`
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+
+error[E0224]: at least one trait is required for an object type
+ --> $DIR/issue-73568-lifetime-after-mut.rs:14:18
+ |
+LL | fn y<'a>(y: &mut 'a + Send) {
+ | ^^
+
+error: aborting due to 5 previous errors; 2 warnings emitted
+
+Some errors have detailed explanations: E0178, E0224, E0423.
+For more information about an error, try `rustc --explain E0178`.
--- /dev/null
+// check-pass
+#![allow(non_upper_case_globals)]
+
+const or: usize = 1;
+const and: usize = 2;
+
+mod or {
+ pub const X: usize = 3;
+}
+
+mod and {
+ pub const X: usize = 4;
+}
+
+fn main() {
+ match 0 {
+ 0 => {}
+ or => {}
+ and => {}
+ or::X => {}
+ and::X => {}
+ _ => {}
+ }
+}
--- /dev/null
+// edition:2018
+
+mod t {
+ async pub fn t() {}
+ //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+ //~| HELP visibility `pub` must come before `async`
+}
--- /dev/null
+error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+ --> $DIR/issue-76437-async.rs:4:11
+ |
+LL | async pub fn t() {}
+ | ------^^^
+ | | |
+ | | expected one of `extern`, `fn`, or `unsafe`
+ | help: visibility `pub` must come before `async`: `pub async`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+mod t {
+ const async unsafe pub fn t() {}
+ //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
+ //~| HELP visibility `pub` must come before `const async unsafe`
+}
--- /dev/null
+error: expected one of `extern` or `fn`, found keyword `pub`
+ --> $DIR/issue-76437-const-async-unsafe.rs:4:24
+ |
+LL | const async unsafe pub fn t() {}
+ | -------------------^^^
+ | | |
+ | | expected one of `extern` or `fn`
+ | help: visibility `pub` must come before `const async unsafe`: `pub const async unsafe`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+mod t {
+ const async pub fn t() {}
+ //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+ //~| HELP visibility `pub` must come before `const async`
+}
--- /dev/null
+error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub`
+ --> $DIR/issue-76437-const-async.rs:4:17
+ |
+LL | const async pub fn t() {}
+ | ------------^^^
+ | | |
+ | | expected one of `extern`, `fn`, or `unsafe`
+ | help: visibility `pub` must come before `const async`: `pub const async`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+mod t {
+ const pub fn t() {}
+ //~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
+ //~| HELP visibility `pub` must come before `const`
+}
--- /dev/null
+error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
+ --> $DIR/issue-76437-const.rs:4:11
+ |
+LL | const pub fn t() {}
+ | ------^^^
+ | | |
+ | | expected one of `async`, `extern`, `fn`, or `unsafe`
+ | help: visibility `pub` must come before `const`: `pub const`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+mod t {
+ unsafe pub(crate) fn t() {}
+ //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
+ //~| HELP visibility `pub(crate)` must come before `unsafe`
+}
--- /dev/null
+error: expected one of `extern` or `fn`, found keyword `pub`
+ --> $DIR/issue-76437-pub-crate-unsafe.rs:4:12
+ |
+LL | unsafe pub(crate) fn t() {}
+ | -------^^^-------
+ | | |
+ | | expected one of `extern` or `fn`
+ | help: visibility `pub(crate)` must come before `unsafe`: `pub(crate) unsafe`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+mod t {
+ unsafe pub fn t() {}
+ //~^ ERROR expected one of `extern` or `fn`, found keyword `pub`
+ //~| HELP visibility `pub` must come before `unsafe`
+}
--- /dev/null
+error: expected one of `extern` or `fn`, found keyword `pub`
+ --> $DIR/issue-76437-unsafe.rs:4:12
+ |
+LL | unsafe pub fn t() {}
+ | -------^^^
+ | | |
+ | | expected one of `extern` or `fn`
+ | help: visibility `pub` must come before `unsafe`: `pub unsafe`
+
+error: aborting due to previous error
+
--- /dev/null
+// run-rustfix
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+fn f(
+ x: u8,
+ y: u8,
+) {}
+//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
+
+fn main() {}
--- /dev/null
+// run-rustfix
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+fn f(
+ x: u8
+ y: u8,
+) {}
+//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
+
+fn main() {}
--- /dev/null
+error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
+ --> $DIR/issue-76597.rs:7:38
+ |
+LL | ... x: u8
+ | -
+ | |
+ | expected one of 7 possible tokens
+ | help: missing `,`
+LL | ... y: u8,
+ | ^ unexpected token
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {}
+
+macro_rules! test {}
+//~^ ERROR unexpected end of macro invocation
--- /dev/null
+error: unexpected end of macro invocation
+ --> $DIR/issue-7970b.rs:3:1
+ |
+LL | macro_rules! test {}
+ | ^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
+
+error: aborting due to previous error
+
--- /dev/null
+trait T { const
+impl //~ ERROR: expected identifier, found keyword `impl`
+}
+
+fn main() {}
--- /dev/null
+error: expected identifier, found keyword `impl`
+ --> $DIR/issue-81806.rs:2:1
+ |
+LL | trait T { const
+ | - while parsing this item list starting here
+LL | impl
+ | ^^^^ expected identifier, found keyword
+LL | }
+ | - the item list ends here
+ |
+help: you can escape reserved keywords to use them as identifiers
+ |
+LL | r#impl
+ | ~~~~~~
+
+error: aborting due to previous error
+
--- /dev/null
+// check-fail
+// ignore-tidy-tab
+
+fn main() {
+ """ " //~ ERROR
+}
--- /dev/null
+error: expected one of `.`, `;`, `?`, `}`, or an operator, found `" "`
+ --> $DIR/issue-83639.rs:5:7
+ |
+LL | """ "
+ | ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
+
+error: aborting due to previous error
+
--- /dev/null
+// error-pattern: this file contains an unclosed delimiter
+// error-pattern: expected one of
+#[i=i::<ښܖ<
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-84104.rs:3:13
+ |
+LL | #[i=i::<ښܖ<
+ | - ^
+ | |
+ | unclosed delimiter
+
+error: expected one of `>`, a const expression, lifetime, or type, found `]`
+ --> $DIR/issue-84104.rs:3:13
+ |
+LL | #[i=i::<ښܖ<
+ | ^ expected one of `>`, a const expression, lifetime, or type
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+fn main() {
+ let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
+ //~^ ERROR expected one of `>`, a const expression
+ //~| ERROR expected one of `>`, a const expression, lifetime, or type, found `}`
+ //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+ //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+ //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+}
+//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `}`
--- /dev/null
+error: expected one of `>`, a const expression, lifetime, or type, found `}`
+ --> $DIR/issue-84117.rs:2:67
+ |
+LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
+ | ------------ ^ expected one of `>`, a const expression, lifetime, or type
+ | | |
+ | | help: use `=` if you meant to assign
+ | while parsing the type for `inner_local`
+
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+ --> $DIR/issue-84117.rs:2:65
+ |
+LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
+ | ^ expected one of 8 possible tokens
+
+error: expected one of `,`, `:`, `=`, or `>`, found `}`
+ --> $DIR/issue-84117.rs:8:1
+ |
+LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
+ | ------------ help: use `=` if you meant to assign - expected one of `,`, `:`, `=`, or `>`
+ | |
+ | while parsing the type for `outer_local`
+...
+LL | }
+ | ^ unexpected token
+
+error: expected one of `>`, a const expression, lifetime, or type, found `}`
+ --> $DIR/issue-84117.rs:2:67
+ |
+LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
+ | ------------ ^ expected one of `>`, a const expression, lifetime, or type
+ | | |
+ | | help: use `=` if you meant to assign
+ | while parsing the type for `inner_local`
+
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+ --> $DIR/issue-84117.rs:2:65
+ |
+LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
+ | ^ expected one of 8 possible tokens
+
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+ --> $DIR/issue-84117.rs:2:33
+ |
+LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
+ | ^ expected one of 8 possible tokens
+
+error: aborting due to 6 previous errors
+
--- /dev/null
+fn f(t:for<>t?)
+//~^ ERROR: expected parameter name
+//~| ERROR: expected one of
+//~| ERROR: expected one of
--- /dev/null
+error: expected parameter name, found `?`
+ --> $DIR/issue-84148-1.rs:1:14
+ |
+LL | fn f(t:for<>t?)
+ | ^ expected parameter name
+
+error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
+ --> $DIR/issue-84148-1.rs:1:14
+ |
+LL | fn f(t:for<>t?)
+ | ^
+ | |
+ | expected one of `(`, `)`, `+`, `,`, `::`, or `<`
+ | help: missing `,`
+
+error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
+ --> $DIR/issue-84148-1.rs:1:15
+ |
+LL | fn f(t:for<>t?)
+ | ^ expected one of `->`, `;`, `where`, or `{`
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// error-pattern: this file contains an unclosed delimiter
+// error-pattern: expected parameter name
+// error-pattern: expected one of
+fn f(t:for<>t?
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-84148-2.rs:4:16
+ |
+LL | fn f(t:for<>t?
+ | - ^
+ | |
+ | unclosed delimiter
+
+error: expected parameter name, found `?`
+ --> $DIR/issue-84148-2.rs:4:14
+ |
+LL | fn f(t:for<>t?
+ | ^ expected parameter name
+
+error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
+ --> $DIR/issue-84148-2.rs:4:14
+ |
+LL | fn f(t:for<>t?
+ | ^
+ | |
+ | expected one of `(`, `)`, `+`, `,`, `::`, or `<`
+ | help: missing `,`
+
+error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
+ --> $DIR/issue-84148-2.rs:4:16
+ |
+LL | fn f(t:for<>t?
+ | ^ expected one of `->`, `;`, `where`, or `{`
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+pub extern
+ "invalid-ab_isize" //~ ERROR invalid ABI
+fn foo() {}
+
+fn main() {}
--- /dev/null
+error[E0703]: invalid ABI: found `invalid-ab_isize`
+ --> $DIR/issue-8537.rs:2:3
+ |
+LL | "invalid-ab_isize"
+ | ^^^^^^^^^^^^^^^^^^ invalid ABI
+ |
+ = help: valid ABIs: Rust, C, C-unwind, cdecl, stdcall, stdcall-unwind, fastcall, vectorcall, thiscall, thiscall-unwind, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, wasm, system, system-unwind, rust-intrinsic, rust-call, platform-intrinsic, unadjusted
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0703`.
--- /dev/null
+const pub () {}
+//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`
+pub fn main() {}
--- /dev/null
+error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub`
+ --> $DIR/issue-86895.rs:1:7
+ |
+LL | const pub () {}
+ | ^^^ expected one of `async`, `extern`, `fn`, or `unsafe`
+
+error: aborting due to previous error
+
--- /dev/null
+// Tests that a suggestion is issued if the user wrote a colon instead of
+// a path separator in a match arm.
+
+enum Foo {
+ Bar,
+ Baz,
+}
+
+fn f() -> Foo { Foo::Bar }
+
+fn g1() {
+ match f() {
+ Foo:Bar => {}
+ //~^ ERROR: expected one of
+ //~| HELP: maybe write a path separator here
+ _ => {}
+ }
+ match f() {
+ Foo::Bar:Baz => {}
+ //~^ ERROR: expected one of
+ //~| HELP: maybe write a path separator here
+ _ => {}
+ }
+ match f() {
+ Foo:Bar::Baz => {}
+ //~^ ERROR: expected one of
+ //~| HELP: maybe write a path separator here
+ _ => {}
+ }
+ match f() {
+ Foo: Bar::Baz if true => {}
+ //~^ ERROR: expected one of
+ //~| HELP: maybe write a path separator here
+ _ => {}
+ }
+ if let Bar:Baz = f() {
+ //~^ ERROR: expected one of
+ //~| HELP: maybe write a path separator here
+ }
+}
+
+fn g1_neg() {
+ match f() {
+ ref Foo: Bar::Baz => {}
+ //~^ ERROR: expected one of
+ _ => {}
+ }
+}
+
+fn g2_neg() {
+ match f() {
+ mut Foo: Bar::Baz => {}
+ //~^ ERROR: expected one of
+ _ => {}
+ }
+}
+
+fn main() {
+ let myfoo = Foo::Bar;
+ match myfoo {
+ Foo::Bar => {}
+ Foo:Bar::Baz => {}
+ //~^ ERROR: expected one of
+ //~| HELP: maybe write a path separator here
+ }
+}
--- /dev/null
+error: expected one of `@` or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:13:12
+ |
+LL | Foo:Bar => {}
+ | ^
+ | |
+ | expected one of `@` or `|`
+ | help: maybe write a path separator here: `::`
+
+error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `{`, or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:19:17
+ |
+LL | Foo::Bar:Baz => {}
+ | ^
+ | |
+ | expected one of 8 possible tokens
+ | help: maybe write a path separator here: `::`
+
+error: expected one of `@` or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:25:12
+ |
+LL | Foo:Bar::Baz => {}
+ | ^
+ | |
+ | expected one of `@` or `|`
+ | help: maybe write a path separator here: `::`
+
+error: expected one of `@` or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:31:12
+ |
+LL | Foo: Bar::Baz if true => {}
+ | ^
+ | |
+ | expected one of `@` or `|`
+ | help: maybe write a path separator here: `::`
+
+error: expected one of `@` or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:36:15
+ |
+LL | if let Bar:Baz = f() {
+ | ^
+ | |
+ | expected one of `@` or `|`
+ | help: maybe write a path separator here: `::`
+
+error: expected one of `=>`, `@`, `if`, or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:44:16
+ |
+LL | ref Foo: Bar::Baz => {}
+ | ^ expected one of `=>`, `@`, `if`, or `|`
+
+error: expected one of `=>`, `@`, `if`, or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:52:16
+ |
+LL | mut Foo: Bar::Baz => {}
+ | ^ expected one of `=>`, `@`, `if`, or `|`
+
+error: expected one of `@` or `|`, found `:`
+ --> $DIR/issue-87086-colon-path-sep.rs:62:12
+ |
+LL | Foo:Bar::Baz => {}
+ | ^
+ | |
+ | expected one of `@` or `|`
+ | help: maybe write a path separator here: `::`
+
+error: aborting due to 8 previous errors
+
--- /dev/null
+// run-rustfix
+// Parser should know when a semicolon is missing.
+// https://github.com/rust-lang/rust/issues/87197
+
+fn main() {
+ let x = 100; //~ ERROR: expected `;`
+ println!("{}", x); //~ ERROR: expected `;`
+ let y = 200; //~ ERROR: expected `;`
+ println!("{}", y);
+}
--- /dev/null
+// run-rustfix
+// Parser should know when a semicolon is missing.
+// https://github.com/rust-lang/rust/issues/87197
+
+fn main() {
+ let x = 100 //~ ERROR: expected `;`
+ println!("{}", x) //~ ERROR: expected `;`
+ let y = 200 //~ ERROR: expected `;`
+ println!("{}", y);
+}
--- /dev/null
+error: expected `;`, found `println`
+ --> $DIR/issue-87197-missing-semicolon.rs:6:16
+ |
+LL | let x = 100
+ | ^ help: add `;` here
+LL | println!("{}", x)
+ | ------- unexpected token
+
+error: expected `;`, found keyword `let`
+ --> $DIR/issue-87197-missing-semicolon.rs:7:22
+ |
+LL | println!("{}", x)
+ | ^ help: add `;` here
+LL | let y = 200
+ | --- unexpected token
+
+error: expected `;`, found `println`
+ --> $DIR/issue-87197-missing-semicolon.rs:8:16
+ |
+LL | let y = 200
+ | ^ help: add `;` here
+LL | println!("{}", y);
+ | ------- unexpected token
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// edition:2018
+
+// Test that even when `const` is already present, the proposed fix is `const const async`,
+// like for `pub pub`.
+
+const async const fn test() {}
+//~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `const`
+//~| NOTE expected one of `extern`, `fn`, or `unsafe`
+//~| HELP `const` must come before `async`
+//~| SUGGESTION const async
+//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
--- /dev/null
+error: expected one of `extern`, `fn`, or `unsafe`, found keyword `const`
+ --> $DIR/const-async-const.rs:6:13
+ |
+LL | const async const fn test() {}
+ | ------^^^^^
+ | | |
+ | | expected one of `extern`, `fn`, or `unsafe`
+ | help: `const` must come before `async`: `const async`
+ |
+ = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+// There is an order to respect for keywords before a function:
+// `<visibility>, const, async, unsafe, extern, "<ABI>"`
+//
+// This test ensures the compiler is helpful about them being misplaced.
+// Visibilities are tested elsewhere.
+
+async unsafe const fn test() {}
+//~^ ERROR expected one of `extern` or `fn`, found keyword `const`
+//~| NOTE expected one of `extern` or `fn`
+//~| HELP `const` must come before `async unsafe`
+//~| SUGGESTION const async unsafe
+//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
--- /dev/null
+error: expected one of `extern` or `fn`, found keyword `const`
+ --> $DIR/several-kw-jump.rs:9:14
+ |
+LL | async unsafe const fn test() {}
+ | -------------^^^^^
+ | | |
+ | | expected one of `extern` or `fn`
+ | help: `const` must come before `async unsafe`: `const async unsafe`
+ |
+ = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+// There is an order to respect for keywords before a function:
+// `<visibility>, const, async, unsafe, extern, "<ABI>"`
+//
+// This test ensures the compiler is helpful about them being misplaced.
+// Visibilities are tested elsewhere.
+
+unsafe async fn test() {}
+//~^ ERROR expected one of `extern` or `fn`, found keyword `async`
+//~| NOTE expected one of `extern` or `fn`
+//~| HELP `async` must come before `unsafe`
+//~| SUGGESTION async unsafe
+//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
--- /dev/null
+error: expected one of `extern` or `fn`, found keyword `async`
+ --> $DIR/wrong-async.rs:9:8
+ |
+LL | unsafe async fn test() {}
+ | -------^^^^^
+ | | |
+ | | expected one of `extern` or `fn`
+ | help: `async` must come before `unsafe`: `async unsafe`
+ |
+ = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+// There is an order to respect for keywords before a function:
+// `<visibility>, const, async, unsafe, extern, "<ABI>"`
+//
+// This test ensures the compiler is helpful about them being misplaced.
+// Visibilities are tested elsewhere.
+
+unsafe const fn test() {}
+//~^ ERROR expected one of `extern` or `fn`, found keyword `const`
+//~| NOTE expected one of `extern` or `fn`
+//~| HELP `const` must come before `unsafe`
+//~| SUGGESTION const unsafe
+//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
--- /dev/null
+error: expected one of `extern` or `fn`, found keyword `const`
+ --> $DIR/wrong-const.rs:9:8
+ |
+LL | unsafe const fn test() {}
+ | -------^^^^^
+ | | |
+ | | expected one of `extern` or `fn`
+ | help: `const` must come before `unsafe`: `const unsafe`
+ |
+ = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+
+error: aborting due to previous error
+
--- /dev/null
+// edition:2018
+
+// There is an order to respect for keywords before a function:
+// `<visibility>, const, async, unsafe, extern, "<ABI>"`
+//
+// This test ensures the compiler is helpful about them being misplaced.
+// Visibilities are tested elsewhere.
+
+extern unsafe fn test() {}
+//~^ ERROR expected `fn`, found keyword `unsafe`
+//~| NOTE expected `fn`
+//~| HELP `unsafe` must come before `extern`
+//~| SUGGESTION unsafe extern
+//~| NOTE keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
--- /dev/null
+error: expected `fn`, found keyword `unsafe`
+ --> $DIR/wrong-unsafe.rs:9:8
+ |
+LL | extern unsafe fn test() {}
+ | -------^^^^^^
+ | | |
+ | | expected `fn`
+ | help: `unsafe` must come before `extern`: `unsafe extern`
+ |
+ = note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
+
+error: aborting due to previous error
+
--- /dev/null
+struct Foo {}
+
+impl Foo {
+ pub fn bar()
+ //~^ ERROR: expected `;`, found `}`
+ //~| ERROR: associated function in `impl` without body
+}
+
+fn main() {}
--- /dev/null
+error: expected `;`, found `}`
+ --> $DIR/issue-87635.rs:4:17
+ |
+LL | pub fn bar()
+ | ^ help: add `;` here
+...
+LL | }
+ | - unexpected token
+
+error: associated function in `impl` without body
+ --> $DIR/issue-87635.rs:4:5
+ |
+LL | pub fn bar()
+ | ^^^^^^^^^^^-
+ | |
+ | help: provide a definition for the function: `{ <body> }`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+macro_rules! foo {
+ ( $f:path ) => {{
+ let _: usize = $f; //~ERROR
+ }};
+}
+
+struct Baz;
+
+fn main() {
+ foo!(Baz);
+}
--- /dev/null
+error[E0308]: mismatched types
+ --> $DIR/issue-87812-path.rs:3:24
+ |
+LL | let _: usize = $f;
+ | ----- ^^ expected `usize`, found struct `Baz`
+ | |
+ | expected due to this
+...
+LL | foo!(Baz);
+ | --------- in this macro invocation
+ |
+ = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+#![deny(break_with_label_and_loop)]
+
+macro_rules! foo {
+ ( $f:block ) => {
+ '_l: loop {
+ break '_l $f; //~ERROR
+ }
+ };
+}
+
+fn main() {
+ let x = foo!({ 3 });
+}
--- /dev/null
+error: this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression
+ --> $DIR/issue-87812.rs:6:13
+ |
+LL | break '_l $f;
+ | ^^^^^^^^^^^^
+...
+LL | let x = foo!({ 3 });
+ | ----------- in this macro invocation
+ |
+note: the lint level is defined here
+ --> $DIR/issue-87812.rs:1:9
+ |
+LL | #![deny(break_with_label_and_loop)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: wrap this expression in parentheses
+ |
+LL | break '_l ($f);
+ | + +
+
+error: aborting due to previous error
+
--- /dev/null
+// run-rustfix
+#[allow(unused_parens)]
+fn main() {
+ let _ = 1; //~ ERROR leading `+` is not supported
+ let _ = (1.0 + 2.0) * 3.0; //~ ERROR leading `+` is not supported
+ //~| ERROR leading `+` is not supported
+ let _ = [3, 4+6]; //~ ERROR leading `+` is not supported
+}
--- /dev/null
+// run-rustfix
+#[allow(unused_parens)]
+fn main() {
+ let _ = +1; //~ ERROR leading `+` is not supported
+ let _ = (1.0 + +2.0) * +3.0; //~ ERROR leading `+` is not supported
+ //~| ERROR leading `+` is not supported
+ let _ = [+3, 4+6]; //~ ERROR leading `+` is not supported
+}
--- /dev/null
+error: leading `+` is not supported
+ --> $DIR/issue-88276-unary-plus.rs:4:13
+ |
+LL | let _ = +1;
+ | ^ unexpected `+`
+ |
+help: try removing the `+`
+ |
+LL - let _ = +1;
+LL + let _ = 1;
+ |
+
+error: leading `+` is not supported
+ --> $DIR/issue-88276-unary-plus.rs:5:20
+ |
+LL | let _ = (1.0 + +2.0) * +3.0;
+ | ^ unexpected `+`
+ |
+help: try removing the `+`
+ |
+LL - let _ = (1.0 + +2.0) * +3.0;
+LL + let _ = (1.0 + 2.0) * +3.0;
+ |
+
+error: leading `+` is not supported
+ --> $DIR/issue-88276-unary-plus.rs:5:28
+ |
+LL | let _ = (1.0 + +2.0) * +3.0;
+ | ^ unexpected `+`
+ |
+help: try removing the `+`
+ |
+LL - let _ = (1.0 + +2.0) * +3.0;
+LL + let _ = (1.0 + +2.0) * 3.0;
+ |
+
+error: leading `+` is not supported
+ --> $DIR/issue-88276-unary-plus.rs:7:14
+ |
+LL | let _ = [+3, 4+6];
+ | ^ unexpected `+`
+ |
+help: try removing the `+`
+ |
+LL - let _ = [+3, 4+6];
+LL + let _ = [3, 4+6];
+ |
+
+error: aborting due to 4 previous errors
+
--- /dev/null
+// check-pass
+
+#![allow(non_camel_case_types)]
+
+struct union;
+
+impl union {
+ pub fn new() -> Self {
+ union { }
+ }
+}
+
+fn main() {
+ let _u = union::new();
+}
--- /dev/null
+// Regression test for the ICE described in #88770.
+
+// error-pattern:this file contains an unclosed delimiter
+// error-pattern:expected one of
+// error-pattern:missing `in` in `for` loop
+// error-pattern:expected `;`, found `e`
+
+fn m(){print!("",(c for&g
+u
+e
+e
--- /dev/null
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-88770.rs:11:3
+ |
+LL | fn m(){print!("",(c for&g
+ | - - - unclosed delimiter
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+...
+LL | e
+ | ^
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-88770.rs:11:3
+ |
+LL | fn m(){print!("",(c for&g
+ | - - - unclosed delimiter
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+...
+LL | e
+ | ^
+
+error: this file contains an unclosed delimiter
+ --> $DIR/issue-88770.rs:11:3
+ |
+LL | fn m(){print!("",(c for&g
+ | - - - unclosed delimiter
+ | | |
+ | | unclosed delimiter
+ | unclosed delimiter
+...
+LL | e
+ | ^
+
+error: missing `in` in `for` loop
+ --> $DIR/issue-88770.rs:8:26
+ |
+LL | fn m(){print!("",(c for&g
+ | __________________________^
+LL | | u
+ | |_ help: try adding `in` here
+
+error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found keyword `for`
+ --> $DIR/issue-88770.rs:8:21
+ |
+LL | fn m(){print!("",(c for&g
+ | ^^^ expected one of 8 possible tokens
+
+error: expected `;`, found `e`
+ --> $DIR/issue-88770.rs:10:2
+ |
+LL | e
+ | ^ help: add `;` here
+LL | e
+ | - unexpected token
+
+error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `)`
+ --> $DIR/issue-88770.rs:11:3
+ |
+LL | e
+ | ^ expected one of 7 possible tokens
+
+error: aborting due to 7 previous errors
+
--- /dev/null
+// Regression test for #88818 (improve error message for missing trait
+// in `impl for X`).
+
+struct S { }
+impl for S { }
+//~^ ERROR: missing trait in a trait impl
+//~| HELP: add a trait here
+//~| HELP: for an inherent impl, drop this `for`
+
+fn main() {}
--- /dev/null
+error: missing trait in a trait impl
+ --> $DIR/issue-88818.rs:5:5
+ |
+LL | impl for S { }
+ | ^
+ |
+help: add a trait here
+ |
+LL | impl Trait for S { }
+ | +++++
+help: for an inherent impl, drop this `for`
+ |
+LL - impl for S { }
+LL + impl S { }
+ |
+
+error: aborting due to previous error
+
--- /dev/null
+// Regression test for #89388.
+
+fn main() {
+ let option: Option<&[u8]> = Some(b"...");
+ let _ = option.map([_]::to_vec);
+ //~^ ERROR: missing angle brackets in associated item path
+}
--- /dev/null
+error: missing angle brackets in associated item path
+ --> $DIR/issue-89388.rs:5:24
+ |
+LL | let _ = option.map([_]::to_vec);
+ | ^^^^^^^^^^^ help: try: `<[_]>::to_vec`
+
+error: aborting due to previous error
+
--- /dev/null
+// Regression test for issue #89396: Try to recover from a
+// `=>` -> `=` or `->` typo in a match arm.
+
+// run-rustfix
+
+fn main() {
+ let opt = Some(42);
+ let _ = match opt {
+ Some(_) => true,
+ //~^ ERROR: expected one of
+ //~| HELP: try using a fat arrow here
+ None => false,
+ //~^ ERROR: expected one of
+ //~| HELP: try using a fat arrow here
+ };
+}
--- /dev/null
+// Regression test for issue #89396: Try to recover from a
+// `=>` -> `=` or `->` typo in a match arm.
+
+// run-rustfix
+
+fn main() {
+ let opt = Some(42);
+ let _ = match opt {
+ Some(_) = true,
+ //~^ ERROR: expected one of
+ //~| HELP: try using a fat arrow here
+ None -> false,
+ //~^ ERROR: expected one of
+ //~| HELP: try using a fat arrow here
+ };
+}
--- /dev/null
+error: expected one of `=>`, `if`, or `|`, found `=`
+ --> $DIR/issue-89396.rs:9:17
+ |
+LL | Some(_) = true,
+ | ^
+ | |
+ | expected one of `=>`, `if`, or `|`
+ | help: try using a fat arrow here: `=>`
+
+error: expected one of `=>`, `@`, `if`, or `|`, found `->`
+ --> $DIR/issue-89396.rs:12:14
+ |
+LL | None -> false,
+ | ^^
+ | |
+ | expected one of `=>`, `@`, `if`, or `|`
+ | help: try using a fat arrow here: `=>`
+
+error: aborting due to 2 previous errors
+
--- /dev/null
+fn main() {
+ const EMPTY_ARRAY = [];
+ //~^ missing type for `const` item
+}
--- /dev/null
+error: missing type for `const` item
+ --> $DIR/issue-89574.rs:2:11
+ |
+LL | const EMPTY_ARRAY = [];
+ | ^^^^^^^^^^^ help: provide a type for the item: `EMPTY_ARRAY: <type>`
+
+error: aborting due to previous error
+
--- /dev/null
+// aux-build:issue-89971-outer-attr-following-inner-attr-ice.rs
+
+#[macro_use]
+extern crate issue_89971_outer_attr_following_inner_attr_ice;
+
+fn main() {
+ Mew();
+ X {};
+}
+
+#![deny(missing_docs)]
+//~^ ERROR an inner attribute is not permitted in this context
+#[derive(ICE)]
+#[deny(missing_docs)]
+struct Mew();
--- /dev/null
+error: an inner attribute is not permitted in this context
+ --> $DIR/issue-89971-outer-attr-following-inner-attr-ice.rs:11:1
+ |
+LL | #![deny(missing_docs)]
+ | ^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | struct Mew();
+ | ------------- the inner attribute doesn't annotate this struct
+ |
+ = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
+help: to annotate the struct, change the attribute from inner to outer style
+ |
+LL - #![deny(missing_docs)]
+LL + #[deny(missing_docs)]
+ |
+
+error: aborting due to previous error
+
--- /dev/null
+fn main() {
+ ...=.
+ //~^ ERROR: unexpected token: `...`
+ //~| ERROR: unexpected `=` after inclusive range
+ //~| ERROR: expected one of `-`, `;`, `}`, or path, found `.`
+}
--- /dev/null
+error: unexpected token: `...`
+ --> $DIR/issue-90993.rs:2:5
+ |
+LL | ...=.
+ | ^^^
+ |
+help: use `..` for an exclusive range
+ |
+LL | ..=.
+ | ~~
+help: or `..=` for an inclusive range
+ |
+LL | ..==.
+ | ~~~
+
+error: unexpected `=` after inclusive range
+ --> $DIR/issue-90993.rs:2:5
+ |
+LL | ...=.
+ | ^^^^ help: use `..=` instead
+ |
+ = note: inclusive ranges end with a single equals sign (`..=`)
+
+error: expected one of `-`, `;`, `}`, or path, found `.`
+ --> $DIR/issue-90993.rs:2:9
+ |
+LL | ...=.
+ | ^ expected one of `-`, `;`, `}`, or path
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// run-pass
+// Testcase for issue #130, operator associativity.
+
+pub fn main() { assert_eq!(3 * 5 / 2, 7); }
|
= help: the trait `Iterator` is not implemented for `bool`
= note: required because of the requirements on the impl of `IntoIterator` for `bool`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
+++ /dev/null
-// edition:2018
-// compile-flags:--extern alloc
-// build-pass
-
-// Test that `--extern alloc` will load from the sysroot without error.
-
-fn main() {
- let _: Vec<i32> = alloc::vec::Vec::new();
-}
--- /dev/null
+// run-pass
+
+#![allow(non_shorthand_field_patterns)]
+#![allow(dead_code)]
+#![allow(unused_variables)]
+
+struct Foo(isize, isize, isize, isize);
+struct Bar{a: isize, b: isize, c: isize, d: isize}
+
+pub fn main() {
+ let Foo(..) = Foo(5, 5, 5, 5);
+ let Foo(..) = Foo(5, 5, 5, 5);
+ let Bar{..} = Bar{a: 5, b: 5, c: 5, d: 5};
+ let (..) = (5, 5, 5, 5);
+ let Foo(a, b, ..) = Foo(5, 5, 5, 5);
+ let Foo(.., d) = Foo(5, 5, 5, 5);
+ let (a, b, ..) = (5, 5, 5, 5);
+ let (.., c, d) = (5, 5, 5, 5);
+ let Bar{b: b, ..} = Bar{a: 5, b: 5, c: 5, d: 5};
+ match [5, 5, 5, 5] {
+ [..] => { }
+ }
+ match [5, 5, 5, 5] {
+ [a, ..] => { }
+ }
+ match [5, 5, 5, 5] {
+ [.., b] => { }
+ }
+ match [5, 5, 5, 5] {
+ [a, .., b] => { }
+ }
+ match [5, 5, 5] {
+ [..] => { }
+ }
+ match [5, 5, 5] {
+ [a, ..] => { }
+ }
+ match [5, 5, 5] {
+ [.., a] => { }
+ }
+ match [5, 5, 5] {
+ [a, .., b] => { }
+ }
+}
#![allow(incomplete_features)]
#![allow(unreachable_code)]
#![feature(const_async_blocks)]
-#![feature(inline_const)]
+#![feature(inline_const_pat)]
fn main() {
match loop {} {
--> $DIR/pat-type-err-let-stmt.rs:6:29
|
LL | let Ok(0): Option<u8> = 42u8;
- | ---------- ^^^^
- | | |
- | | expected enum `Option`, found `u8`
- | | help: try using a variant of the expected enum: `Some(42u8)`
+ | ---------- ^^^^ expected enum `Option`, found `u8`
+ | |
| expected due to this
|
= note: expected enum `Option<u8>`
found type `u8`
+help: try wrapping the expression in `Some`
+ |
+LL | let Ok(0): Option<u8> = Some(42u8);
+ | +++++ +
error[E0308]: mismatched types
--> $DIR/pat-type-err-let-stmt.rs:6:9
+++ /dev/null
-fn main() {
- let x = -5;
- if x<-1 { //~ ERROR unexpected token: `<-`
- println!("ok");
- }
-}
+++ /dev/null
-error: unexpected token: `<-`
- --> $DIR/placement-syntax.rs:3:9
- |
-LL | if x<-1 {
- | ^^
- |
-help: if you meant to write a comparison against a negative value, add a space in between `<` and `-`
- |
-LL | if x< -1 {
- | ~~~
-
-error: aborting due to previous error
-
--- /dev/null
+#![crate_type = "lib"]
+
+pub struct Fish {
+ pub x: isize
+}
+
+mod unexported {
+ use super::Fish;
+ impl PartialEq for Fish {
+ fn eq(&self, _: &Fish) -> bool { true }
+ fn ne(&self, _: &Fish) -> bool { false }
+ }
+}
--- /dev/null
+use inner_private_module::*;
+
+mod inner_private_module {
+ pub struct Unnameable1;
+ pub struct Unnameable2;
+ #[derive(Clone, Copy)]
+ pub struct Unnameable3;
+ pub struct Unnameable4;
+ pub struct Unnameable5;
+ pub struct Unnameable6;
+ pub struct Unnameable7;
+ #[derive(Default)]
+ pub struct Unnameable8;
+ pub enum UnnameableEnum {
+ NameableVariant
+ }
+ pub trait UnnameableTrait {
+ type Alias: Default;
+ }
+
+ impl Unnameable1 {
+ pub fn method_of_unnameable_type1(&self) -> &'static str {
+ "Hello1"
+ }
+ }
+ impl Unnameable2 {
+ pub fn method_of_unnameable_type2(&self) -> &'static str {
+ "Hello2"
+ }
+ }
+ impl Unnameable3 {
+ pub fn method_of_unnameable_type3(&self) -> &'static str {
+ "Hello3"
+ }
+ }
+ impl Unnameable4 {
+ pub fn method_of_unnameable_type4(&self) -> &'static str {
+ "Hello4"
+ }
+ }
+ impl Unnameable5 {
+ pub fn method_of_unnameable_type5(&self) -> &'static str {
+ "Hello5"
+ }
+ }
+ impl Unnameable6 {
+ pub fn method_of_unnameable_type6(&self) -> &'static str {
+ "Hello6"
+ }
+ }
+ impl Unnameable7 {
+ pub fn method_of_unnameable_type7(&self) -> &'static str {
+ "Hello7"
+ }
+ }
+ impl Unnameable8 {
+ pub fn method_of_unnameable_type8(&self) -> &'static str {
+ "Hello8"
+ }
+ }
+ impl UnnameableEnum {
+ pub fn method_of_unnameable_enum(&self) -> &'static str {
+ "HelloEnum"
+ }
+ }
+}
+
+pub fn function_returning_unnameable_type() -> Unnameable1 {
+ Unnameable1
+}
+
+pub const CONSTANT_OF_UNNAMEABLE_TYPE: Unnameable2 =
+ Unnameable2;
+
+pub fn function_accepting_unnameable_type(_: Option<Unnameable3>) {}
+
+pub type AliasOfUnnameableType = Unnameable4;
+
+impl Unnameable1 {
+ pub fn inherent_method_returning_unnameable_type(&self) -> Unnameable5 {
+ Unnameable5
+ }
+}
+
+pub trait Tr {
+ fn trait_method_returning_unnameable_type(&self) -> Unnameable6 {
+ Unnameable6
+ }
+}
+impl Tr for Unnameable1 {}
+
+pub use inner_private_module::UnnameableEnum::NameableVariant;
+
+pub struct Struct {
+ pub field_of_unnameable_type: Unnameable7
+}
+
+pub static STATIC: Struct = Struct { field_of_unnameable_type: Unnameable7 } ;
+
+impl UnnameableTrait for AliasOfUnnameableType {
+ type Alias = Unnameable8;
+}
+
+pub fn generic_function<T: UnnameableTrait>() -> T::Alias {
+ Default::default()
+}
--- /dev/null
+fn f1() {}
+enum E1 { V }
+struct S1 {
+ #[rustfmt::skip]
+ bar: i32,
+}
+mod m1 {
+ pub use ::f1; //~ ERROR `f1` is only public within the crate, and cannot be re-exported outside
+ pub use ::S1; //~ ERROR `S1` is only public within the crate, and cannot be re-exported outside
+ pub use ::E1; //~ ERROR `E1` is only public within the crate, and cannot be re-exported outside
+ pub use ::E1::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside
+}
+
+pub(crate) fn f2() {}
+pub(crate) enum E2 {
+ V
+}
+pub(crate) struct S2 {
+ #[rustfmt::skip]
+ bar: i32,
+}
+mod m2 {
+ pub use ::f2; //~ ERROR `f2` is only public within the crate, and cannot be re-exported outside
+ pub use ::S2; //~ ERROR `S2` is only public within the crate, and cannot be re-exported outside
+ pub use ::E2; //~ ERROR `E2` is only public within the crate, and cannot be re-exported outside
+ pub use ::E2::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside
+}
+
+mod m3 {
+ pub(crate) fn f3() {}
+ pub(crate) enum E3 {
+ V
+ }
+ pub(crate) struct S3 {
+ #[rustfmt::skip]
+ bar: i32,
+ }
+}
+pub use m3::f3; //~ ERROR `f3` is only public within the crate, and cannot be re-exported outside
+pub use m3::S3; //~ ERROR `S3` is only public within the crate, and cannot be re-exported outside
+pub use m3::E3; //~ ERROR `E3` is only public within the crate, and cannot be re-exported outside
+pub use m3::E3::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside
+
+pub(self) fn f4() {}
+pub use ::f4 as f5; //~ ERROR `f4` is only public within the crate, and cannot be re-exported outside
+
+pub mod m10 {
+ pub mod m {
+ pub(super) fn f6() {}
+ pub(crate) fn f7() {}
+ pub(in crate::m10) fn f8() {}
+ }
+ pub use self::m::f6; //~ ERROR `f6` is private, and cannot be re-exported
+ pub use self::m::f7; //~ ERROR `f7` is only public within the crate, and cannot be re-exported outside
+ pub use self::m::f8; //~ ERROR `f8` is private, and cannot be re-exported
+}
+pub use m10::m::f6; //~ ERROR function `f6` is private
+pub use m10::m::f7; //~ ERROR `f7` is only public within the crate, and cannot be re-exported outside
+pub use m10::m::f8; //~ ERROR function `f8` is private
+
+pub mod m11 {
+ pub(self) fn f9() {}
+}
+pub use m11::f9; //~ ERROR function `f9` is private
+
+fn main() {}
--- /dev/null
+error[E0364]: `f1` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:8:13
+ |
+LL | pub use ::f1;
+ | ^^^^
+ |
+note: consider marking `f1` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:8:13
+ |
+LL | pub use ::f1;
+ | ^^^^
+
+error[E0365]: `S1` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:9:13
+ |
+LL | pub use ::S1;
+ | ^^^^ re-export of crate public `S1`
+ |
+ = note: consider declaring type or module `S1` with `pub`
+
+error[E0365]: `E1` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:10:13
+ |
+LL | pub use ::E1;
+ | ^^^^ re-export of crate public `E1`
+ |
+ = note: consider declaring type or module `E1` with `pub`
+
+error[E0364]: `V` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:11:13
+ |
+LL | pub use ::E1::V;
+ | ^^^^^^^
+ |
+note: consider marking `V` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:11:13
+ |
+LL | pub use ::E1::V;
+ | ^^^^^^^
+
+error[E0364]: `f2` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:23:13
+ |
+LL | pub use ::f2;
+ | ^^^^
+ |
+note: consider marking `f2` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:23:13
+ |
+LL | pub use ::f2;
+ | ^^^^
+
+error[E0365]: `S2` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:24:13
+ |
+LL | pub use ::S2;
+ | ^^^^ re-export of crate public `S2`
+ |
+ = note: consider declaring type or module `S2` with `pub`
+
+error[E0365]: `E2` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:25:13
+ |
+LL | pub use ::E2;
+ | ^^^^ re-export of crate public `E2`
+ |
+ = note: consider declaring type or module `E2` with `pub`
+
+error[E0364]: `V` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:26:13
+ |
+LL | pub use ::E2::V;
+ | ^^^^^^^
+ |
+note: consider marking `V` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:26:13
+ |
+LL | pub use ::E2::V;
+ | ^^^^^^^
+
+error[E0364]: `f3` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:39:9
+ |
+LL | pub use m3::f3;
+ | ^^^^^^
+ |
+note: consider marking `f3` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:39:9
+ |
+LL | pub use m3::f3;
+ | ^^^^^^
+
+error[E0365]: `S3` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:40:9
+ |
+LL | pub use m3::S3;
+ | ^^^^^^ re-export of crate public `S3`
+ |
+ = note: consider declaring type or module `S3` with `pub`
+
+error[E0365]: `E3` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:41:9
+ |
+LL | pub use m3::E3;
+ | ^^^^^^ re-export of crate public `E3`
+ |
+ = note: consider declaring type or module `E3` with `pub`
+
+error[E0364]: `V` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:42:9
+ |
+LL | pub use m3::E3::V;
+ | ^^^^^^^^^
+ |
+note: consider marking `V` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:42:9
+ |
+LL | pub use m3::E3::V;
+ | ^^^^^^^^^
+
+error[E0364]: `f4` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:45:9
+ |
+LL | pub use ::f4 as f5;
+ | ^^^^^^^^^^
+ |
+note: consider marking `f4` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:45:9
+ |
+LL | pub use ::f4 as f5;
+ | ^^^^^^^^^^
+
+error[E0364]: `f6` is private, and cannot be re-exported
+ --> $DIR/crate-private-reexport.rs:53:13
+ |
+LL | pub use self::m::f6;
+ | ^^^^^^^^^^^
+ |
+note: consider marking `f6` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:53:13
+ |
+LL | pub use self::m::f6;
+ | ^^^^^^^^^^^
+
+error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:54:13
+ |
+LL | pub use self::m::f7;
+ | ^^^^^^^^^^^
+ |
+note: consider marking `f7` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:54:13
+ |
+LL | pub use self::m::f7;
+ | ^^^^^^^^^^^
+
+error[E0364]: `f8` is private, and cannot be re-exported
+ --> $DIR/crate-private-reexport.rs:55:13
+ |
+LL | pub use self::m::f8;
+ | ^^^^^^^^^^^
+ |
+note: consider marking `f8` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:55:13
+ |
+LL | pub use self::m::f8;
+ | ^^^^^^^^^^^
+
+error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/crate-private-reexport.rs:58:9
+ |
+LL | pub use m10::m::f7;
+ | ^^^^^^^^^^
+ |
+note: consider marking `f7` as `pub` in the imported module
+ --> $DIR/crate-private-reexport.rs:58:9
+ |
+LL | pub use m10::m::f7;
+ | ^^^^^^^^^^
+
+error[E0603]: function `f6` is private
+ --> $DIR/crate-private-reexport.rs:57:17
+ |
+LL | pub use m10::m::f6;
+ | ^^ private function
+ |
+note: the function `f6` is defined here
+ --> $DIR/crate-private-reexport.rs:49:9
+ |
+LL | pub(super) fn f6() {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error[E0603]: function `f8` is private
+ --> $DIR/crate-private-reexport.rs:59:17
+ |
+LL | pub use m10::m::f8;
+ | ^^ private function
+ |
+note: the function `f8` is defined here
+ --> $DIR/crate-private-reexport.rs:51:9
+ |
+LL | pub(in crate::m10) fn f8() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0603]: function `f9` is private
+ --> $DIR/crate-private-reexport.rs:64:14
+ |
+LL | pub use m11::f9;
+ | ^^ private function
+ |
+note: the function `f9` is defined here
+ --> $DIR/crate-private-reexport.rs:62:5
+ |
+LL | pub(self) fn f9() {}
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 20 previous errors
+
+Some errors have detailed explanations: E0364, E0365, E0603.
+For more information about an error, try `rustc --explain E0364`.
--- /dev/null
+mod foo {
+ pub fn x() { }
+
+ enum Y { Y1 }
+}
+
+fn main() { let z = foo::Y::Y1; } //~ ERROR: enum `Y` is private
--- /dev/null
+error[E0603]: enum `Y` is private
+ --> $DIR/export-tag-variant.rs:7:26
+ |
+LL | fn main() { let z = foo::Y::Y1; }
+ | ^ private enum
+ |
+note: the enum `Y` is defined here
+ --> $DIR/export-tag-variant.rs:4:5
+ |
+LL | enum Y { Y1 }
+ | ^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0603`.
--- /dev/null
+// run-pass
+// aux-build:impl_privacy_xc_2.rs
+
+extern crate impl_privacy_xc_2;
+
+pub fn main() {
+ let fish1 = impl_privacy_xc_2::Fish { x: 1 };
+ let fish2 = impl_privacy_xc_2::Fish { x: 2 };
+ if fish1.eq(&fish2) { println!("yes") } else { println!("no") };
+}
mod m1 {
- pub use ::E::V; //~ ERROR `V` is private, and cannot be re-exported
+ pub use ::E::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside
}
mod m2 {
- pub use ::E::{V}; //~ ERROR `V` is private, and cannot be re-exported
+ pub use ::E::{V}; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside
}
mod m3 {
- pub use ::E::V::{self}; //~ ERROR `V` is private, and cannot be re-exported
+ pub use ::E::V::{self}; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside
}
#[deny(unused_imports)]
-error[E0364]: `V` is private, and cannot be re-exported
+error[E0364]: `V` is only public within the crate, and cannot be re-exported outside
--> $DIR/private-variant-reexport.rs:2:13
|
LL | pub use ::E::V;
LL | pub use ::E::V;
| ^^^^^^
-error[E0364]: `V` is private, and cannot be re-exported
+error[E0364]: `V` is only public within the crate, and cannot be re-exported outside
--> $DIR/private-variant-reexport.rs:6:19
|
LL | pub use ::E::{V};
LL | pub use ::E::{V};
| ^
-error[E0365]: `V` is private, and cannot be re-exported
+error[E0365]: `V` is only public within the crate, and cannot be re-exported outside
--> $DIR/private-variant-reexport.rs:10:22
|
LL | pub use ::E::V::{self};
- | ^^^^ re-export of private `V`
+ | ^^^^ re-export of crate public `V`
|
= note: consider declaring type or module `V` with `pub`
--- /dev/null
+// run-pass
+// ignore-wasm32-bare compiled with panic=abort by default
+// aux-build:reachable-unnameable-items.rs
+
+extern crate reachable_unnameable_items;
+use reachable_unnameable_items::*;
+
+fn main() {
+ let res1 = function_returning_unnameable_type().method_of_unnameable_type1();
+ let res2 = CONSTANT_OF_UNNAMEABLE_TYPE.method_of_unnameable_type2();
+ let res4 = AliasOfUnnameableType{}.method_of_unnameable_type4();
+ let res5 = function_returning_unnameable_type().inherent_method_returning_unnameable_type().
+ method_of_unnameable_type5();
+ let res6 = function_returning_unnameable_type().trait_method_returning_unnameable_type().
+ method_of_unnameable_type6();
+ let res7 = STATIC.field_of_unnameable_type.method_of_unnameable_type7();
+ let res8 = generic_function::<AliasOfUnnameableType>().method_of_unnameable_type8();
+ let res_enum = NameableVariant.method_of_unnameable_enum();
+ assert_eq!(res1, "Hello1");
+ assert_eq!(res2, "Hello2");
+ assert_eq!(res4, "Hello4");
+ assert_eq!(res5, "Hello5");
+ assert_eq!(res6, "Hello6");
+ assert_eq!(res7, "Hello7");
+ assert_eq!(res8, "Hello8");
+ assert_eq!(res_enum, "HelloEnum");
+
+ let none = None;
+ function_accepting_unnameable_type(none);
+ let _guard = std::panic::catch_unwind(|| none.unwrap().method_of_unnameable_type3());
+}
--- /dev/null
+// run-pass
+
+#![allow(unused_must_use)]
+#![allow(stable_features)]
+#![allow(deprecated)]
+#![allow(unused_imports)]
+// compile-flags:--test
+// ignore-emscripten no processes
+// ignore-sgx no processes
+// ignore-vxworks no 'cat' and 'sleep'
+
+// N.B., these tests kill child processes. Valgrind sees these children as leaking
+// memory, which makes for some *confusing* logs. That's why these are here
+// instead of in std.
+
+#![feature(rustc_private, duration)]
+
+extern crate libc;
+
+use std::process::{self, Command, Child, Output, Stdio};
+use std::str;
+use std::sync::mpsc::channel;
+use std::thread;
+use std::time::Duration;
+
+macro_rules! t {
+ ($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("error: {}", e) })
+}
+
+#[test]
+fn test_destroy_once() {
+ let mut p = sleeper();
+ t!(p.kill());
+}
+
+#[cfg(unix)]
+pub fn sleeper() -> Child {
+ t!(Command::new("sleep").arg("1000").spawn())
+}
+#[cfg(windows)]
+pub fn sleeper() -> Child {
+ // There's a `timeout` command on windows, but it doesn't like having
+ // its output piped, so instead just ping ourselves a few times with
+ // gaps in between so we're sure this process is alive for awhile
+ t!(Command::new("ping").arg("127.0.0.1").arg("-n").arg("1000").spawn())
+}
+
+#[test]
+fn test_destroy_twice() {
+ let mut p = sleeper();
+ t!(p.kill()); // this shouldn't crash...
+ let _ = p.kill(); // ...and nor should this (and nor should the destructor)
+}
+
+#[test]
+fn test_destroy_actually_kills() {
+ let cmd = if cfg!(windows) {
+ "cmd"
+ } else if cfg!(target_os = "android") {
+ "/system/bin/cat"
+ } else {
+ "cat"
+ };
+
+ // this process will stay alive indefinitely trying to read from stdin
+ let mut p = t!(Command::new(cmd)
+ .stdin(Stdio::piped())
+ .spawn());
+
+ t!(p.kill());
+
+ // Don't let this test time out, this should be quick
+ let (tx, rx) = channel();
+ thread::spawn(move|| {
+ thread::sleep_ms(1000);
+ if rx.try_recv().is_err() {
+ process::exit(1);
+ }
+ });
+ let code = t!(p.wait()).code();
+ if cfg!(windows) {
+ assert!(code.is_some());
+ } else {
+ assert!(code.is_none());
+ }
+ tx.send(());
+}
--- /dev/null
+// run-pass
+// ignore-emscripten no processes
+// ignore-sgx no processes
+
+fn check_for_no_backtrace(test: std::process::Output) {
+ assert!(!test.status.success());
+ let err = String::from_utf8_lossy(&test.stderr);
+ let mut it = err.lines();
+
+ assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked at")), Some(true));
+ assert_eq!(it.next(), Some("note: run with `RUST_BACKTRACE=1` \
+ environment variable to display a backtrace"));
+ assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true));
+ assert_eq!(it.next(), None);
+}
+
+fn main() {
+ let args: Vec<String> = std::env::args().collect();
+ if args.len() > 1 && args[1] == "run_test" {
+ let _ = std::thread::spawn(|| {
+ panic!();
+ }).join();
+
+ panic!();
+ } else {
+ let test = std::process::Command::new(&args[0]).arg("run_test")
+ .env_remove("RUST_BACKTRACE")
+ .output()
+ .unwrap();
+ check_for_no_backtrace(test);
+ let test = std::process::Command::new(&args[0]).arg("run_test")
+ .env("RUST_BACKTRACE","0")
+ .output()
+ .unwrap();
+ check_for_no_backtrace(test);
+ }
+}
--- /dev/null
+// run-pass
+// ignore-android
+// ignore-emscripten no processes
+// ignore-sgx no processes
+// revisions: mir thir
+// [thir]compile-flags: -Zthir-unsafeck
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+use std::process::{Command, Stdio};
+use std::env;
+use std::io::{self, Read, Write};
+
+#[cfg(unix)]
+unsafe fn without_stdio<R, F: FnOnce() -> R>(f: F) -> R {
+ let doit = |a| {
+ let r = libc::dup(a);
+ assert!(r >= 0);
+ return r
+ };
+ let a = doit(0);
+ let b = doit(1);
+ let c = doit(2);
+
+ assert!(libc::close(0) >= 0);
+ assert!(libc::close(1) >= 0);
+ assert!(libc::close(2) >= 0);
+
+ let r = f();
+
+ assert!(libc::dup2(a, 0) >= 0);
+ assert!(libc::dup2(b, 1) >= 0);
+ assert!(libc::dup2(c, 2) >= 0);
+
+ return r
+}
+
+#[cfg(unix)]
+fn assert_fd_is_valid(fd: libc::c_int) {
+ if unsafe { libc::fcntl(fd, libc::F_GETFD) == -1 } {
+ panic!("file descriptor {} is not valid: {}", fd, io::Error::last_os_error());
+ }
+}
+
+#[cfg(windows)]
+fn assert_fd_is_valid(_fd: libc::c_int) {}
+
+#[cfg(windows)]
+unsafe fn without_stdio<R, F: FnOnce() -> R>(f: F) -> R {
+ type DWORD = u32;
+ type HANDLE = *mut u8;
+ type BOOL = i32;
+
+ const STD_INPUT_HANDLE: DWORD = -10i32 as DWORD;
+ const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD;
+ const STD_ERROR_HANDLE: DWORD = -12i32 as DWORD;
+ const INVALID_HANDLE_VALUE: HANDLE = !0 as HANDLE;
+
+ extern "system" {
+ fn GetStdHandle(which: DWORD) -> HANDLE;
+ fn SetStdHandle(which: DWORD, handle: HANDLE) -> BOOL;
+ }
+
+ let doit = |id| {
+ let handle = GetStdHandle(id);
+ assert!(handle != INVALID_HANDLE_VALUE);
+ assert!(SetStdHandle(id, INVALID_HANDLE_VALUE) != 0);
+ return handle
+ };
+
+ let a = doit(STD_INPUT_HANDLE);
+ let b = doit(STD_OUTPUT_HANDLE);
+ let c = doit(STD_ERROR_HANDLE);
+
+ let r = f();
+
+ let doit = |id, handle| {
+ assert!(SetStdHandle(id, handle) != 0);
+ };
+ doit(STD_INPUT_HANDLE, a);
+ doit(STD_OUTPUT_HANDLE, b);
+ doit(STD_ERROR_HANDLE, c);
+
+ return r
+}
+
+fn main() {
+ if env::args().len() > 1 {
+ // Writing to stdout & stderr should not panic.
+ println!("test");
+ assert!(io::stdout().write(b"test\n").is_ok());
+ assert!(io::stderr().write(b"test\n").is_ok());
+
+ // Stdin should be at EOF.
+ assert_eq!(io::stdin().read(&mut [0; 10]).unwrap(), 0);
+
+ // Standard file descriptors should be valid on UNIX:
+ assert_fd_is_valid(0);
+ assert_fd_is_valid(1);
+ assert_fd_is_valid(2);
+ return
+ }
+
+ // First, make sure reads/writes without stdio work if stdio itself is
+ // missing.
+ let (a, b, c) = unsafe {
+ without_stdio(|| {
+ let a = io::stdout().write(b"test\n");
+ let b = io::stderr().write(b"test\n");
+ let c = io::stdin().read(&mut [0; 10]);
+
+ (a, b, c)
+ })
+ };
+
+ assert_eq!(a.unwrap(), 5);
+ assert_eq!(b.unwrap(), 5);
+ assert_eq!(c.unwrap(), 0);
+
+ // Second, spawn a child and do some work with "null" descriptors to make
+ // sure it's ok
+ let me = env::current_exe().unwrap();
+ let status = Command::new(&me)
+ .arg("next")
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status().unwrap();
+ assert!(status.success(), "{} isn't a success", status);
+
+ // Finally, close everything then spawn a child to make sure everything is
+ // *still* ok.
+ let status = unsafe {
+ without_stdio(|| Command::new(&me).arg("next").status())
+ }.unwrap();
+ assert!(status.success(), "{} isn't a success", status);
+}
--- /dev/null
+// run-pass
+
+#![allow(stable_features)]
+// ignore-emscripten no processes
+// ignore-sgx no processes
+
+#![feature(process_try_wait)]
+
+use std::env;
+use std::process::Command;
+use std::thread;
+use std::time::Duration;
+
+fn main() {
+ let args = env::args().collect::<Vec<_>>();
+ if args.len() != 1 {
+ match &args[1][..] {
+ "sleep" => thread::sleep(Duration::new(1_000, 0)),
+ _ => {}
+ }
+ return
+ }
+
+ let mut me = Command::new(env::current_exe().unwrap())
+ .arg("sleep")
+ .spawn()
+ .unwrap();
+ let maybe_status = me.try_wait().unwrap();
+ assert!(maybe_status.is_none());
+ let maybe_status = me.try_wait().unwrap();
+ assert!(maybe_status.is_none());
+
+ me.kill().unwrap();
+ me.wait().unwrap();
+
+ let status = me.try_wait().unwrap().unwrap();
+ assert!(!status.success());
+ let status = me.try_wait().unwrap().unwrap();
+ assert!(!status.success());
+
+ let mut me = Command::new(env::current_exe().unwrap())
+ .arg("return-quickly")
+ .spawn()
+ .unwrap();
+ loop {
+ match me.try_wait() {
+ Ok(Some(res)) => {
+ assert!(res.success());
+ break
+ }
+ Ok(None) => {
+ thread::sleep(Duration::from_millis(1));
+ }
+ Err(e) => panic!("error in try_wait: {}", e),
+ }
+ }
+
+ let status = me.try_wait().unwrap().unwrap();
+ assert!(status.success());
+}
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-// Regression test for #37154: the problem here was that the cache
-// results in a false error because it was caching placeholder results
-// even after those placeholder regions had been popped.
-
-trait Foo {
- fn method(&self) {}
-}
-
-struct Wrapper<T>(T);
-
-impl<T> Foo for Wrapper<T> where for<'a> &'a T: IntoIterator<Item=&'a ()> {}
-
-fn f(x: Wrapper<Vec<()>>) {
- x.method(); // This works.
- x.method(); // error: no method named `method`
-}
-
-fn main() { }
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-// Check that functions can modify local state.
-
-// pretty-expanded FIXME #23616
-
-fn sums_to(v: Vec<isize> , sum: isize) -> bool {
- let mut i = 0;
- let mut sum0 = 0;
- while i < v.len() {
- sum0 += v[i];
- i += 1;
- }
- return sum0 == sum;
-}
-
-fn sums_to_using_uniq(v: Vec<isize> , sum: isize) -> bool {
- let mut i = 0;
- let mut sum0: Box<_> = 0.into();
- while i < v.len() {
- *sum0 += v[i];
- i += 1;
- }
- return *sum0 == sum;
-}
-
-fn sums_to_using_rec(v: Vec<isize> , sum: isize) -> bool {
- let mut i = 0;
- let mut sum0 = F {f: 0};
- while i < v.len() {
- sum0.f += v[i];
- i += 1;
- }
- return sum0.f == sum;
-}
-
-struct F<T> { f: T }
-
-fn sums_to_using_uniq_rec(v: Vec<isize> , sum: isize) -> bool {
- let mut i = 0;
- let mut sum0 = F::<Box<_>> {f: 0.into() };
- while i < v.len() {
- *sum0.f += v[i];
- i += 1;
- }
- return *sum0.f == sum;
-}
-
-pub fn main() {
-}
+++ /dev/null
-// run-pass
-
-#![allow(unused_must_use)]
-// Make sure the type inference for the new range expression work as
-// good as the old one. Check out issue #21672, #21595 and #21649 for
-// more details.
-
-
-fn main() {
- let xs = (0..8).map(|i| i == 1u64).collect::<Vec<_>>();
- assert_eq!(xs[1], true);
- let xs = (0..8).map(|i| 1u64 == i).collect::<Vec<_>>();
- assert_eq!(xs[1], true);
- let xs: Vec<u8> = (0..10).collect();
- assert_eq!(xs.len(), 10);
-
- for x in 0..10 { x % 2; }
- for x in 0..100 { x as f32; }
-
- let array = [true, false];
- for i in 0..1 { array[i]; }
-}
|
= note: required because of the requirements on the impl of `Iterator` for `std::ops::Range<bool>`
= note: required because of the requirements on the impl of `IntoIterator` for `std::ops::Range<bool>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
--> $DIR/range-1.rs:14:17
| ^^^^^^^^^^^^^^^ no implementation for `std::ops::Range<usize> < std::ops::Range<usize>` and `std::ops::Range<usize> > std::ops::Range<usize>`
|
= help: the trait `PartialOrd` is not implemented for `std::ops::Range<usize>`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't compare `std::ops::RangeTo<usize>` with `std::ops::RangeTo<usize>`
| ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo<usize> < std::ops::RangeTo<usize>` and `std::ops::RangeTo<usize> > std::ops::RangeTo<usize>`
|
= help: the trait `PartialOrd` is not implemented for `std::ops::RangeTo<usize>`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't compare `std::ops::RangeFrom<usize>` with `std::ops::RangeFrom<usize>`
| ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom<usize> < std::ops::RangeFrom<usize>` and `std::ops::RangeFrom<usize> > std::ops::RangeFrom<usize>`
|
= help: the trait `PartialOrd` is not implemented for `std::ops::RangeFrom<usize>`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull`
| ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull`
|
= help: the trait `PartialOrd` is not implemented for `std::ops::RangeFull`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't compare `std::ops::RangeInclusive<usize>` with `std::ops::RangeInclusive<usize>`
| ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive<usize> < std::ops::RangeInclusive<usize>` and `std::ops::RangeInclusive<usize> > std::ops::RangeInclusive<usize>`
|
= help: the trait `PartialOrd` is not implemented for `std::ops::RangeInclusive<usize>`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: can't compare `std::ops::RangeToInclusive<usize>` with `std::ops::RangeToInclusive<usize>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive<usize> < std::ops::RangeToInclusive<usize>` and `std::ops::RangeToInclusive<usize> > std::ops::RangeToInclusive<usize>`
|
= help: the trait `PartialOrd` is not implemented for `std::ops::RangeToInclusive<usize>`
-note: required by `std::cmp::PartialOrd::partial_cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `std::ops::Range<usize>: Ord` is not satisfied
LL | a: Range<usize>,
| ^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::Range<usize>`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `std::ops::RangeTo<usize>: Ord` is not satisfied
LL | b: RangeTo<usize>,
| ^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeTo<usize>`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `std::ops::RangeFrom<usize>: Ord` is not satisfied
LL | c: RangeFrom<usize>,
| ^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFrom<usize>`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `std::ops::RangeFull: Ord` is not satisfied
LL | d: RangeFull,
| ^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFull`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `std::ops::RangeInclusive<usize>: Ord` is not satisfied
LL | e: RangeInclusive<usize>,
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeInclusive<usize>`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `std::ops::RangeToInclusive<usize>: Ord` is not satisfied
LL | f: RangeToInclusive<usize>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeToInclusive<usize>`
|
-note: required by `std::cmp::Ord::cmp`
- --> $SRC_DIR/core/src/cmp.rs:LL:COL
- |
-LL | fn cmp(&self, other: &Self) -> Ordering;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 12 previous errors
+++ /dev/null
-// run-pass
-// check raw fat pointer ops
-
-use std::mem;
-
-fn assert_inorder<T: PartialEq + PartialOrd>(a: &[T]) {
- for i in 0..a.len() {
- for j in 0..a.len() {
- if i < j {
- assert!(a[i] < a[j]);
- assert!(a[i] <= a[j]);
- assert!(!(a[i] == a[j]));
- assert!(a[i] != a[j]);
- assert!(!(a[i] >= a[j]));
- assert!(!(a[i] > a[j]));
- } else if i == j {
- assert!(!(a[i] < a[j]));
- assert!(a[i] <= a[j]);
- assert!(a[i] == a[j]);
- assert!(!(a[i] != a[j]));
- assert!(a[i] >= a[j]);
- assert!(!(a[i] > a[j]));
- } else {
- assert!(!(a[i] < a[j]));
- assert!(!(a[i] <= a[j]));
- assert!(!(a[i] == a[j]));
- assert!(a[i] != a[j]);
- assert!(a[i] >= a[j]);
- assert!(a[i] > a[j]);
- }
- }
- }
-}
-
-trait Foo { fn foo(&self) -> usize; }
-impl<T> Foo for T {
- fn foo(&self) -> usize {
- mem::size_of::<T>()
- }
-}
-
-struct S<T:?Sized>(u32, T);
-
-fn main() {
- let mut array = [0,1,2,3,4];
- let mut array2 = [5,6,7,8,9];
-
- // fat ptr comparison: addr then extra
-
- // check ordering for arrays
- let mut ptrs: Vec<*const [u8]> = vec![
- &array[0..0], &array[0..1], &array, &array[1..]
- ];
-
- let array_addr = &array as *const [u8] as *const u8 as usize;
- let array2_addr = &array2 as *const [u8] as *const u8 as usize;
- if array2_addr < array_addr {
- ptrs.insert(0, &array2);
- } else {
- ptrs.push(&array2);
- }
- assert_inorder(&ptrs);
-
- // check ordering for mut arrays
- let mut ptrs: Vec<*mut [u8]> = vec![
- &mut array[0..0], &mut array[0..1], &mut array, &mut array[1..]
- ];
-
- let array_addr = &mut array as *mut [u8] as *mut u8 as usize;
- let array2_addr = &mut array2 as *mut [u8] as *mut u8 as usize;
- if array2_addr < array_addr {
- ptrs.insert(0, &mut array2);
- } else {
- ptrs.push(&mut array2);
- }
- assert_inorder(&ptrs);
-
- let mut u8_ = (0u8, 1u8);
- let mut u32_ = (4u32, 5u32);
-
- // check ordering for ptrs
- let buf: &mut [*const dyn Foo] = &mut [
- &u8_, &u8_.0,
- &u32_, &u32_.0,
- ];
- buf.sort_by(|u,v| {
- let u : [*const (); 2] = unsafe { mem::transmute(*u) };
- let v : [*const (); 2] = unsafe { mem::transmute(*v) };
- u.cmp(&v)
- });
- assert_inorder(buf);
-
- // check ordering for mut ptrs
- let buf: &mut [*mut dyn Foo] = &mut [
- &mut u8_, &mut u8_.0,
- &mut u32_, &mut u32_.0,
- ];
- buf.sort_by(|u,v| {
- let u : [*const (); 2] = unsafe { mem::transmute(*u) };
- let v : [*const (); 2] = unsafe { mem::transmute(*v) };
- u.cmp(&v)
- });
- assert_inorder(buf);
-
- // check ordering for structs containing arrays
- let ss: (S<[u8; 2]>,
- S<[u8; 3]>,
- S<[u8; 2]>) = (
- S(7, [8, 9]),
- S(10, [11, 12, 13]),
- S(4, [5, 6])
- );
- assert_inorder(&[
- &ss.0 as *const S<[u8]>,
- &ss.1 as *const S<[u8]>,
- &ss.2 as *const S<[u8]>
- ]);
-}
+++ /dev/null
-// run-pass
-// ignore-wasm32-bare compiled with panic=abort by default
-// aux-build:reachable-unnameable-items.rs
-
-extern crate reachable_unnameable_items;
-use reachable_unnameable_items::*;
-
-fn main() {
- let res1 = function_returning_unnameable_type().method_of_unnameable_type1();
- let res2 = CONSTANT_OF_UNNAMEABLE_TYPE.method_of_unnameable_type2();
- let res4 = AliasOfUnnameableType{}.method_of_unnameable_type4();
- let res5 = function_returning_unnameable_type().inherent_method_returning_unnameable_type().
- method_of_unnameable_type5();
- let res6 = function_returning_unnameable_type().trait_method_returning_unnameable_type().
- method_of_unnameable_type6();
- let res7 = STATIC.field_of_unnameable_type.method_of_unnameable_type7();
- let res8 = generic_function::<AliasOfUnnameableType>().method_of_unnameable_type8();
- let res_enum = NameableVariant.method_of_unnameable_enum();
- assert_eq!(res1, "Hello1");
- assert_eq!(res2, "Hello2");
- assert_eq!(res4, "Hello4");
- assert_eq!(res5, "Hello5");
- assert_eq!(res6, "Hello6");
- assert_eq!(res7, "Hello7");
- assert_eq!(res8, "Hello8");
- assert_eq!(res_enum, "HelloEnum");
-
- let none = None;
- function_accepting_unnameable_type(none);
- let _guard = std::panic::catch_unwind(|| none.unwrap().method_of_unnameable_type3());
-}
fn main() {
for _ in unimplemented!() as Void {}
//~^ ERROR unreachable pattern
- //~^^ ERROR unreachable pattern
}
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-error: unreachable pattern
- --> $DIR/unreachable-loop-patterns.rs:18:14
- |
-LL | for _ in unimplemented!() as Void {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
+++ /dev/null
-// run-pass
-// pretty-expanded FIXME #23616
-
-mod a {
- pub fn f() {}
- pub fn g() {}
-}
-
-mod b {
- pub use a::*;
-}
-
-pub fn main() {
- b::f();
- b::g();
-}
LL | Foo.some_method::<&'a isize>();
| ^^^^^^^^^^^
|
- = note: type must satisfy the static lifetime
+note: type must satisfy the static lifetime as required by this binding
+ --> $DIR/regions-bounded-method-type-parameters.rs:8:22
+ |
+LL | fn some_method<A:'static>(self) { }
+ | ^^^^^^^
error: aborting due to previous error
| - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | // oh dear!
LL | Box::new(B(&*v)) as Box<dyn X>
- | ^ ...so that the type `T` will meet its required lifetime bounds
+ | ^ ...so that the type `T` will meet its required lifetime bounds...
+ |
+note: ...that is required by this bound
+ --> $DIR/regions-close-object-into-object-5.rs:9:17
+ |
+LL | struct B<'a, T: 'a>(&'a (A<T> + 'a));
+ | ^^
error[E0310]: the parameter type `T` may not live long enough
--> $DIR/regions-close-object-into-object-5.rs:17:14
--- /dev/null
+// run-pass
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+// Test that the `wf` checker properly handles bound regions in object
+// types. Compiling this code used to trigger an ICE.
+
+// pretty-expanded FIXME #23616
+
+pub struct Context<'tcx> {
+ vec: &'tcx Vec<isize>
+}
+
+pub type Cmd<'a> = &'a isize;
+
+pub type DecodeInlinedItem<'a> =
+ Box<dyn for<'tcx> FnMut(Cmd, &Context<'tcx>) -> Result<&'tcx isize, ()> + 'a>;
+
+fn foo(d: DecodeInlinedItem) {
+}
+
+fn main() { }
--- /dev/null
+#![crate_type="lib"]
+
+pub const X: () = ();
--- /dev/null
+#![crate_type="lib"]
+
+pub const Y: () = ();
--- /dev/null
+// run-pass
+// aux-build:blind-item-mixed-crate-use-item-foo.rs
+// aux-build:blind-item-mixed-crate-use-item-foo2.rs
+
+// pretty-expanded FIXME #23616
+
+mod m {
+ pub fn f<T>(_: T, _: (), _: ()) { }
+ pub fn g<T>(_: T, _: (), _: ()) { }
+}
+
+const BAR: () = ();
+struct Data;
+use m::f;
+extern crate blind_item_mixed_crate_use_item_foo as foo;
+
+fn main() {
+ const BAR2: () = ();
+ struct Data2;
+ use m::g;
+
+ extern crate blind_item_mixed_crate_use_item_foo2 as foo2;
+
+ f(Data, BAR, foo::X);
+ g(Data2, BAR2, foo2::Y);
+}
--- /dev/null
+// run-pass
+// pretty-expanded FIXME #23616
+
+mod m {
+ pub fn f<T>(_: T, _: ()) { }
+ pub fn g<T>(_: T, _: ()) { }
+}
+
+const BAR: () = ();
+struct Data;
+use m::f;
+
+fn main() {
+ const BAR2: () = ();
+ struct Data2;
+ use m::g;
+
+ f(Data, BAR);
+ g(Data2, BAR2);
+}
--- /dev/null
+// In this test baz isn't resolved when called as foo.baz even though
+// it's called from inside foo. This is somewhat surprising and may
+// want to change eventually.
+
+mod foo {
+ pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of undeclared crate or module `foo`
+
+ fn baz() { }
+}
+
+fn main() { }
--- /dev/null
+error[E0433]: failed to resolve: use of undeclared crate or module `foo`
+ --> $DIR/export-fully-qualified.rs:6:20
+ |
+LL | pub fn bar() { foo::baz(); }
+ | ^^^ use of undeclared crate or module `foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0433`.
|
= note: while checking the return type of the `async fn`
= note: expected fn pointer `fn()`
- found fn pointer `fn() -> impl Future`
+ found fn pointer `fn() -> impl Future<Output = ()>`
error: aborting due to 6 previous errors
--- /dev/null
+// run-pass
+
+#![no_std]
+
+extern crate std;
+
+fn main() {
+ let a = Some("foo");
+ a.unwrap();
+}
--- /dev/null
+// run-pass
+
+#![no_std]
+
+extern crate std;
+
+fn main() {
+ let a = core::option::Option::Some("foo");
+ a.unwrap();
+}
--- /dev/null
+// run-pass
+
+#![no_std]
+
+extern crate std;
+
+mod foo {
+ pub fn test() -> Option<i32> {
+ Some(2)
+ }
+}
+
+fn main() {
+ let a = core::option::Option::Some("foo");
+ a.unwrap();
+ foo::test().unwrap();
+}
--- /dev/null
+// edition:2018
+// compile-flags:--extern alloc
+// build-pass
+
+// Test that `--extern alloc` will load from the sysroot without error.
+
+fn main() {
+ let _: Vec<i32> = alloc::vec::Vec::new();
+}
|
help: `Z::Unit` is a unit variant, you need to write it without the parentheses
|
-LL | let _ = Z::Unit;
- | ~~~~~~~
+LL - let _ = Z::Unit();
+LL + let _ = Z::Unit;
+ |
error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:43:16
|
help: `m::E::Unit` is a unit variant, you need to write it without the parentheses
|
-LL | let _: E = m::E::Unit;
- | ~~~~~~~~~~
+LL - let _: E = m::E::Unit();
+LL + let _: E = m::E::Unit;
+ |
error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:51:16
|
help: `E::Unit` is a unit variant, you need to write it without the parentheses
|
-LL | let _: E = E::Unit;
- | ~~~~~~~
+LL - let _: E = E::Unit();
+LL + let _: E = E::Unit;
+ |
error: aborting due to 23 previous errors
+++ /dev/null
-#![allow(warnings)]
-
-pub fn fail(x: Option<&(Iterator<Item=()>+Send)>)
- -> Option<&Iterator<Item=()>> {
- // This call used to trigger an LLVM assertion because the return
- // slot had type "Option<&Iterator>"* instead of
- // "Option<&(Iterator+Send)>"* -- but this now yields a
- // compilation error and I'm not sure how to create a comparable
- // test. To ensure that this PARTICULAR failure doesn't occur
- // again, though, I've left this test here, so if this ever starts
- // to compile again, we can adjust the test appropriately (clearly
- // it should never ICE...). -nmatsakis
- inner(x) //~ ERROR mismatched types
-}
-
-pub fn inner(x: Option<&(Iterator<Item=()>+Send)>)
- -> Option<&(Iterator<Item=()>+Send)> {
- x
-}
-
-
-fn main() {}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/retslot-cast.rs:13:5
- |
-LL | -> Option<&Iterator<Item=()>> {
- | -------------------------- expected `Option<&dyn Iterator<Item = ()>>` because of return type
-...
-LL | inner(x)
- | ^^^^^^^^ expected trait `Iterator<Item = ()>`, found trait `Iterator<Item = ()> + Send`
- |
- = note: expected enum `Option<&dyn Iterator<Item = ()>>`
- found enum `Option<&dyn Iterator<Item = ()> + Send>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
| ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool`
|
= help: the trait `Try` is not implemented for `bool`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/disallowed-positions.rs:44:19
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<_>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:54:8
| ^^ the `?` operator cannot be applied to type `{integer}`
|
= help: the trait `Try` is not implemented for `{integer}`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:94:11
| ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool`
|
= help: the trait `Try` is not implemented for `bool`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/disallowed-positions.rs:108:22
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<_>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:118:11
| ^^ the `?` operator cannot be applied to type `{integer}`
|
= help: the trait `Try` is not implemented for `{integer}`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0614]: type `bool` cannot be dereferenced
--> $DIR/disallowed-positions.rs:171:5
| ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool`
|
= help: the trait `Try` is not implemented for `bool`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/disallowed-positions.rs:181:16
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<_>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/disallowed-positions.rs:196:10
| ^^ the `?` operator cannot be applied to type `{integer}`
|
= help: the trait `Try` is not implemented for `{integer}`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 103 previous errors; 1 warning emitted
#[link(name = "foo", kind = "raw-dylib")]
extern "C" {
- #[link_ordinal(1)]
+ #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes
#[link_ordinal(2)]
- //~^ ERROR multiple `link_ordinal` attributes on a single definition
fn foo();
}
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
-error: multiple `link_ordinal` attributes on a single definition
+error: multiple `link_ordinal` attributes
+ --> $DIR/link-ordinal-multiple.rs:7:5
+ |
+LL | #[link_ordinal(1)]
+ | ^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
--> $DIR/link-ordinal-multiple.rs:8:5
|
LL | #[link_ordinal(2)]
LL | impl const std::ops::Add for i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: and another `impl` found in the `core` crate: `impl Add for i32;`
-note: required by a bound in `Add`
- --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
- |
-LL | / pub trait Add<Rhs = Self> {
-LL | | /// The resulting type after applying the `+` operator.
-LL | | #[stable(feature = "rust1", since = "1.0.0")]
-LL | | type Output;
-... |
-LL | | fn add(self, rhs: Rhs) -> Self::Output;
-LL | | }
- | |_^ required by this bound in `Add`
error[E0283]: type annotations needed
--> $DIR/const-and-non-const-impl.rs:14:6
...
LL | impl const std::ops::Add for Int {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: required by a bound in `Add`
- --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
- |
-LL | / pub trait Add<Rhs = Self> {
-LL | | /// The resulting type after applying the `+` operator.
-LL | | #[stable(feature = "rust1", since = "1.0.0")]
-LL | | type Output;
-... |
-LL | | fn add(self, rhs: Rhs) -> Self::Output;
-LL | | }
- | |_^ required by this bound in `Add`
error[E0283]: type annotations needed
--> $DIR/const-and-non-const-impl.rs:22:12
...
LL | impl const std::ops::Add for Int {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: required by a bound in `Add`
- --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
- |
-LL | / pub trait Add<Rhs = Self> {
-LL | | /// The resulting type after applying the `+` operator.
-LL | | #[stable(feature = "rust1", since = "1.0.0")]
-LL | | type Output;
-... |
-LL | | fn add(self, rhs: Rhs) -> Self::Output;
-LL | | }
- | |_^ required by this bound in `Add`
error: aborting due to 5 previous errors
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
-note: required by `ConstDropImplWithBounds`
- --> $DIR/const-drop-fail.rs:27:1
+note: required by a bound in `ConstDropImplWithBounds`
+ --> $DIR/const-drop-fail.rs:27:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
--> $DIR/const-drop-fail.rs:49:5
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
-note: required by `ConstDropImplWithBounds`
- --> $DIR/const-drop-fail.rs:27:1
+note: required by a bound in `ConstDropImplWithBounds`
+ --> $DIR/const-drop-fail.rs:27:35
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
--> $DIR/const-drop-fail.rs:49:5
LL | T::b();
| ^^^^ the trait `Bar` is not implemented for `T`
|
-note: required by `Foo::b`
- --> $DIR/trait-where-clause.rs:8:5
+note: required by a bound in `Foo::b`
+ --> $DIR/trait-where-clause.rs:8:24
|
LL | fn b() where Self: ~const Bar;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^ required by this bound in `Foo::b`
help: consider further restricting this bound
|
LL | const fn test1<T: ~const Foo + Bar + Bar>() {
LL | T::c::<T>();
| ^^^^^^^^^ the trait `Bar` is not implemented for `T`
|
-note: required by `Foo::c`
- --> $DIR/trait-where-clause.rs:9:5
+note: required by a bound in `Foo::c`
+ --> $DIR/trait-where-clause.rs:9:13
|
LL | fn c<T: ~const Bar>();
- | ^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^ required by this bound in `Foo::c`
help: consider further restricting this bound
|
LL | const fn test1<T: ~const Foo + Bar + Bar>() {
LL | T::b();
| ^^^^ the trait `Bar` is not implemented for `T`
|
-note: required by `Foo::b`
- --> $DIR/trait-where-clause.rs:8:5
+note: required by a bound in `Foo::b`
+ --> $DIR/trait-where-clause.rs:8:24
|
LL | fn b() where Self: ~const Bar;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^ required by this bound in `Foo::b`
help: consider further restricting this bound
|
LL | fn test3<T: Foo + Bar>() {
LL | T::c::<T>();
| ^^^^^^^^^ the trait `Bar` is not implemented for `T`
|
-note: required by `Foo::c`
- --> $DIR/trait-where-clause.rs:9:5
+note: required by a bound in `Foo::c`
+ --> $DIR/trait-where-clause.rs:9:13
|
LL | fn c<T: ~const Bar>();
- | ^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^ required by this bound in `Foo::c`
help: consider further restricting this bound
|
LL | fn test3<T: Foo + Bar>() {
--- /dev/null
+// run-pass
+
+#![allow(unused_must_use)]
+#![allow(deprecated)]
+// ignore-emscripten no threads support
+// ignore-sgx no processes
+
+use std::{env, fmt, process, sync, thread};
+
+struct SlowFmt(u32);
+impl fmt::Debug for SlowFmt {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ thread::sleep_ms(3);
+ self.0.fmt(f)
+ }
+}
+
+fn do_print(x: u32) {
+ let x = SlowFmt(x);
+ println!("{:?}{:?}{:?}{:?}{:?}", x, x, x, x, x);
+}
+
+fn main(){
+ if env::args().count() == 2 {
+ let barrier = sync::Arc::new(sync::Barrier::new(2));
+ let tbarrier = barrier.clone();
+ let t = thread::spawn(move || {
+ tbarrier.wait();
+ do_print(1);
+ });
+ barrier.wait();
+ do_print(2);
+ t.join();
+ } else {
+ let this = env::args().next().unwrap();
+ let output = process::Command::new(this).arg("-").output().unwrap();
+ for line in String::from_utf8(output.stdout).unwrap().lines() {
+ match line.chars().next().unwrap() {
+ '1' => assert_eq!(line, "11111"),
+ '2' => assert_eq!(line, "22222"),
+ chr => panic!("unexpected character {:?}", chr)
+ }
+ }
+ }
+}
--- /dev/null
+// run-pass
+// ignore-test: not a test, used by backtrace-debuginfo.rs to test file!()
+
+#[inline(never)]
+pub fn callback<F>(f: F) where F: FnOnce((&'static str, u32)) {
+ f((file!(), line!()))
+}
+
+// We emit the wrong location for the caller here when inlined on MSVC
+#[cfg_attr(not(target_env = "msvc"), inline(always))]
+#[cfg_attr(target_env = "msvc", inline(never))]
+pub fn callback_inlined<F>(f: F) where F: FnOnce((&'static str, u32)) {
+ f((file!(), line!()))
+}
--- /dev/null
+// run-pass
+// We disable tail merging here because it can't preserve debuginfo and thus
+// potentially breaks the backtraces. Also, subtle changes can decide whether
+// tail merging succeeds, so the test might work today but fail tomorrow due to a
+// seemingly completely unrelated change.
+// Unfortunately, LLVM has no "disable" option for this, so we have to set
+// "enable" to 0 instead.
+
+// compile-flags:-g -Copt-level=0 -Cllvm-args=-enable-tail-merge=0
+// compile-flags:-Cforce-frame-pointers=yes
+// ignore-pretty issue #37195
+// ignore-emscripten spawning processes is not supported
+// ignore-sgx no processes
+
+use std::env;
+
+#[path = "backtrace-debuginfo-aux.rs"] mod aux;
+
+macro_rules! pos {
+ () => ((file!(), line!()))
+}
+
+macro_rules! dump_and_die {
+ ($($pos:expr),*) => ({
+ // FIXME(#18285): we cannot include the current position because
+ // the macro span takes over the last frame's file/line.
+ //
+ // You might also be wondering why a major platform,
+ // i686-pc-windows-msvc, is located in here. Some of the saga can be
+ // found on #62897, but the tl;dr; is that it appears that if the
+ // standard library doesn't have debug information or frame pointers,
+ // which it doesn't by default on the test builders, then the stack
+ // walking routines in dbghelp will randomly terminate the stack trace
+ // in libstd without going further. Presumably the addition of frame
+ // pointers and/or debuginfo fixes this since tests always work with
+ // nightly compilers (which have debuginfo). In general though this test
+ // is replicated in rust-lang/backtrace-rs and has extensive coverage
+ // there, even on i686-pc-windows-msvc. We do the best we can in
+ // rust-lang/rust to test it as well, but sometimes we just gotta keep
+ // landing PRs.
+ if cfg!(any(target_os = "android",
+ all(target_os = "linux", target_arch = "arm"),
+ all(target_env = "msvc", target_arch = "x86"),
+ target_os = "freebsd",
+ target_os = "dragonfly",
+ target_os = "openbsd")) {
+ // skip these platforms as this support isn't implemented yet.
+ } else {
+ dump_filelines(&[$($pos),*]);
+ panic!();
+ }
+ })
+}
+
+// we can't use a function as it will alter the backtrace
+macro_rules! check {
+ ($counter:expr; $($pos:expr),*) => ({
+ if *$counter == 0 {
+ dump_and_die!($($pos),*)
+ } else {
+ *$counter -= 1;
+ }
+ })
+}
+
+type Pos = (&'static str, u32);
+
+// this goes to stdout and each line has to be occurred
+// in the following backtrace to stderr with a correct order.
+fn dump_filelines(filelines: &[Pos]) {
+ for &(file, line) in filelines.iter().rev() {
+ // extract a basename
+ let basename = file.split(&['/', '\\'][..]).last().unwrap();
+ println!("{}:{}", basename, line);
+ }
+}
+
+#[inline(never)]
+fn inner(counter: &mut i32, main_pos: Pos, outer_pos: Pos) {
+ check!(counter; main_pos, outer_pos);
+ check!(counter; main_pos, outer_pos);
+ let inner_pos = pos!(); aux::callback(|aux_pos| {
+ check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
+ });
+ let inner_pos = pos!(); aux::callback_inlined(|aux_pos| {
+ check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
+ });
+}
+
+// We emit the wrong location for the caller here when inlined on MSVC
+#[cfg_attr(not(target_env = "msvc"), inline(always))]
+#[cfg_attr(target_env = "msvc", inline(never))]
+fn inner_inlined(counter: &mut i32, main_pos: Pos, outer_pos: Pos) {
+ check!(counter; main_pos, outer_pos);
+ check!(counter; main_pos, outer_pos);
+
+ // Again, disable inlining for MSVC.
+ #[cfg_attr(not(target_env = "msvc"), inline(always))]
+ #[cfg_attr(target_env = "msvc", inline(never))]
+ fn inner_further_inlined(counter: &mut i32, main_pos: Pos, outer_pos: Pos, inner_pos: Pos) {
+ check!(counter; main_pos, outer_pos, inner_pos);
+ }
+ inner_further_inlined(counter, main_pos, outer_pos, pos!());
+
+ let inner_pos = pos!(); aux::callback(|aux_pos| {
+ check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
+ });
+ let inner_pos = pos!(); aux::callback_inlined(|aux_pos| {
+ check!(counter; main_pos, outer_pos, inner_pos, aux_pos);
+ });
+
+ // this tests a distinction between two independent calls to the inlined function.
+ // (un)fortunately, LLVM somehow merges two consecutive such calls into one node.
+ inner_further_inlined(counter, main_pos, outer_pos, pos!());
+}
+
+#[inline(never)]
+fn outer(mut counter: i32, main_pos: Pos) {
+ inner(&mut counter, main_pos, pos!());
+ inner_inlined(&mut counter, main_pos, pos!());
+}
+
+fn check_trace(output: &str, error: &str) -> Result<(), String> {
+ // reverse the position list so we can start with the last item (which was the first line)
+ let mut remaining: Vec<&str> = output.lines().map(|s| s.trim()).rev().collect();
+
+ if !error.contains("stack backtrace") {
+ return Err(format!("no backtrace found in stderr:\n{}", error))
+ }
+ for line in error.lines() {
+ if !remaining.is_empty() && line.contains(remaining.last().unwrap()) {
+ remaining.pop();
+ }
+ }
+ if !remaining.is_empty() {
+ return Err(format!("trace does not match position list\n\
+ still need to find {:?}\n\n\
+ --- stdout\n{}\n\
+ --- stderr\n{}",
+ remaining, output, error))
+ }
+ Ok(())
+}
+
+fn run_test(me: &str) {
+ use std::str;
+ use std::process::Command;
+
+ let mut i = 0;
+ let mut errors = Vec::new();
+ loop {
+ let out = Command::new(me)
+ .env("RUST_BACKTRACE", "full")
+ .arg(i.to_string()).output().unwrap();
+ let output = str::from_utf8(&out.stdout).unwrap();
+ let error = str::from_utf8(&out.stderr).unwrap();
+ if out.status.success() {
+ assert!(output.contains("done."), "bad output for successful run: {}", output);
+ break;
+ } else {
+ if let Err(e) = check_trace(output, error) {
+ errors.push(e);
+ }
+ }
+ i += 1;
+ }
+ if errors.len() > 0 {
+ for error in errors {
+ println!("---------------------------------------");
+ println!("{}", error);
+ }
+
+ panic!("found some errors");
+ }
+}
+
+#[inline(never)]
+fn main() {
+ let args: Vec<String> = env::args().collect();
+ if args.len() >= 2 {
+ let case = args[1].parse().unwrap();
+ eprintln!("test case {}", case);
+ outer(case, pos!());
+ println!("done.");
+ } else {
+ run_test(&args[0]);
+ }
+}
--- /dev/null
+// run-pass
+
+#![feature(start)]
+
+#[start]
+pub fn main(_: isize, _: *const *const u8) -> isize {
+ println!("hello");
+ 0
+}
use legacy_macro as _; // OK
pub(crate) use legacy_macro as _; // OK
- pub use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported
+ pub use legacy_macro as _; //~ ERROR `legacy_macro` is only public within the crate, and cannot be re-exported outside
}
mod m2 {
-error[E0364]: `legacy_macro` is private, and cannot be re-exported
+error[E0364]: `legacy_macro` is only public within the crate, and cannot be re-exported outside
--> $DIR/macro-rules.rs:11:13
|
LL | pub use legacy_macro as _;
+++ /dev/null
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:13:13
- |
-LL | let b = B;
- | ^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:14:14
- |
-LL | let rb = &B;
- | ^^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:15:14
- |
-LL | let xb = XB;
- | ^^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:16:15
- |
-LL | let xrb = &XB;
- | ^^^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
+++ /dev/null
-// aux-build:extern-statics.rs
-// revisions: mir thir
-// [thir]compile-flags: -Z thir-unsafeck
-
-extern crate extern_statics;
-use extern_statics::*;
-
-extern "C" {
- static mut B: u8;
-}
-
-fn main() {
- let b = B; //~ ERROR use of mutable static is unsafe
- let rb = &B; //~ ERROR use of mutable static is unsafe
- let xb = XB; //~ ERROR use of mutable static is unsafe
- let xrb = &XB; //~ ERROR use of mutable static is unsafe
-}
+++ /dev/null
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:13:13
- |
-LL | let b = B;
- | ^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:14:15
- |
-LL | let rb = &B;
- | ^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:15:14
- |
-LL | let xb = XB;
- | ^^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of mutable static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics-mut.rs:16:16
- |
-LL | let xrb = &XB;
- | ^^ use of mutable static
- |
- = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
+++ /dev/null
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:13:13
- |
-LL | let a = A;
- | ^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:14:14
- |
-LL | let ra = &A;
- | ^^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:15:14
- |
-LL | let xa = XA;
- | ^^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:16:15
- |
-LL | let xra = &XA;
- | ^^^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
+++ /dev/null
-// aux-build:extern-statics.rs
-// revisions: mir thir
-// [thir]compile-flags: -Z thir-unsafeck
-
-extern crate extern_statics;
-use extern_statics::*;
-
-extern "C" {
- static A: u8;
-}
-
-fn main() {
- let a = A; //~ ERROR use of extern static is unsafe
- let ra = &A; //~ ERROR use of extern static is unsafe
- let xa = XA; //~ ERROR use of extern static is unsafe
- let xra = &XA; //~ ERROR use of extern static is unsafe
-}
+++ /dev/null
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:13:13
- |
-LL | let a = A;
- | ^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:14:15
- |
-LL | let ra = &A;
- | ^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:15:14
- |
-LL | let xa = XA;
- | ^^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error[E0133]: use of extern static is unsafe and requires unsafe function or block
- --> $DIR/safe-extern-statics.rs:16:16
- |
-LL | let xra = &XA;
- | ^^ use of extern static
- |
- = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
// ignore-emscripten FIXME(#45351) hits an LLVM assert
#![feature(repr_simd, platform_intrinsics)]
-#![allow(incomplete_features)]
#![feature(inline_const)]
#[repr(simd)]
|
LL | let a: u8 = Tr::C;
| ^^^^^ the trait `Tr` is not implemented for `u8`
- |
-note: required by `Tr::C`
- --> $DIR/issue-29595.rs:2:5
- |
-LL | const C: Self;
- | ^^^^^^^^^^^^^^
error: aborting due to previous error
LL | println!("{}", MyStruct.foo_one());
| ^^^^^^^ method cannot be called on `MyStruct` due to unsatisfied trait bounds
|
- = note: the following trait bounds were not satisfied:
- `MyStruct: Foo`
+note: the following trait bounds were not satisfied because of the requirements of the implementation of `Foo` for `_`:
+ `MyStruct: Foo`
+ --> $DIR/specialization-trait-not-implemented.rs:14:17
+ |
+LL | default impl<T> Foo for T {
+ | ^^^ ^
note: the following trait must be implemented
--> $DIR/specialization-trait-not-implemented.rs:7:1
|
--- /dev/null
+fn main() {
+ let _ = std::thread::thread_info::current_thread();
+ //~^ERROR module `thread_info` is private
+}
--- /dev/null
+error[E0603]: module `thread_info` is private
+ --> $DIR/stability-in-private-module.rs:2:26
+ |
+LL | let _ = std::thread::thread_info::current_thread();
+ | ^^^^^^^^^^^ private module
+ |
+note: the module `thread_info` is defined here
+ --> $SRC_DIR/std/src/thread/mod.rs:LL:COL
+ |
+LL | use crate::sys_common::thread_info;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0603`.
--- /dev/null
+fn main() {
+ let _: Vec<u8, _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api'
+ #[rustfmt::skip]
+ let _: Vec<
+ String,
+ _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api'
+ let _ = Vec::<u16, _>::new(); //~ ERROR use of unstable library feature 'allocator_api'
+ let _boxed: Box<u32, _> = Box::new(10); //~ ERROR use of unstable library feature 'allocator_api'
+}
--- /dev/null
+error[E0658]: use of unstable library feature 'allocator_api'
+ --> $DIR/suggest-vec-allocator-api.rs:2:20
+ |
+LL | let _: Vec<u8, _> = vec![];
+ | ----^
+ | |
+ | help: consider wrapping the inner types in tuple: `(u8, _)`
+ |
+ = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
+ = help: add `#![feature(allocator_api)]` to the crate attributes to enable
+
+error[E0658]: use of unstable library feature 'allocator_api'
+ --> $DIR/suggest-vec-allocator-api.rs:6:9
+ |
+LL | _> = vec![];
+ | ^
+ |
+ = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
+ = help: add `#![feature(allocator_api)]` to the crate attributes to enable
+help: consider wrapping the inner types in tuple
+ |
+LL ~ let _: Vec<(
+LL + String,
+LL ~ _)> = vec![];
+ |
+
+error[E0658]: use of unstable library feature 'allocator_api'
+ --> $DIR/suggest-vec-allocator-api.rs:8:26
+ |
+LL | let _boxed: Box<u32, _> = Box::new(10);
+ | ^
+ |
+ = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
+ = help: add `#![feature(allocator_api)]` to the crate attributes to enable
+
+error[E0658]: use of unstable library feature 'allocator_api'
+ --> $DIR/suggest-vec-allocator-api.rs:7:24
+ |
+LL | let _ = Vec::<u16, _>::new();
+ | -----^
+ | |
+ | help: consider wrapping the inner types in tuple: `(u16, _)`
+ |
+ = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information
+ = help: add `#![feature(allocator_api)]` to the crate attributes to enable
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
+++ /dev/null
-fn main() {
- let _ = std::thread::thread_info::current_thread();
- //~^ERROR module `thread_info` is private
-}
+++ /dev/null
-error[E0603]: module `thread_info` is private
- --> $DIR/stability-in-private-module.rs:2:26
- |
-LL | let _ = std::thread::thread_info::current_thread();
- | ^^^^^^^^^^^ private module
- |
-note: the module `thread_info` is defined here
- --> $SRC_DIR/std/src/thread/mod.rs:LL:COL
- |
-LL | use crate::sys_common::thread_info;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0603`.
--- /dev/null
+warning: `-Z stack-protector=all` is not supported for target nvptx64-nvidia-cuda and will be ignored
+
+warning: 1 warning emitted
+
--- /dev/null
+warning: `-Z stack-protector=basic` is not supported for target nvptx64-nvidia-cuda and will be ignored
+
+warning: 1 warning emitted
+
--- /dev/null
+// build-pass
+// revisions: all strong basic
+// compile-flags: --target nvptx64-nvidia-cuda
+// needs-llvm-components: nvptx
+// [all] compile-flags: -Z stack-protector=all
+// [strong] compile-flags: -Z stack-protector=strong
+// [basic] compile-flags: -Z stack-protector=basic
+
+#![crate_type = "lib"]
+#![feature(no_core, lang_items)]
+#![no_std]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+
+pub fn main(){}
--- /dev/null
+warning: `-Z stack-protector=strong` is not supported for target nvptx64-nvidia-cuda and will be ignored
+
+warning: 1 warning emitted
+
--- /dev/null
+extern "C" {
+ pub static XA: u8;
+ pub static mut XB: u8;
+}
--- /dev/null
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:13:13
+ |
+LL | let b = B;
+ | ^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:14:14
+ |
+LL | let rb = &B;
+ | ^^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:15:14
+ |
+LL | let xb = XB;
+ | ^^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:16:15
+ |
+LL | let xrb = &XB;
+ | ^^^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
--- /dev/null
+// aux-build:extern-statics.rs
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
+extern crate extern_statics;
+use extern_statics::*;
+
+extern "C" {
+ static mut B: u8;
+}
+
+fn main() {
+ let b = B; //~ ERROR use of mutable static is unsafe
+ let rb = &B; //~ ERROR use of mutable static is unsafe
+ let xb = XB; //~ ERROR use of mutable static is unsafe
+ let xrb = &XB; //~ ERROR use of mutable static is unsafe
+}
--- /dev/null
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:13:13
+ |
+LL | let b = B;
+ | ^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:14:15
+ |
+LL | let rb = &B;
+ | ^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:15:14
+ |
+LL | let xb = XB;
+ | ^^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of mutable static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics-mut.rs:16:16
+ |
+LL | let xrb = &XB;
+ | ^^ use of mutable static
+ |
+ = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
--- /dev/null
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:13:13
+ |
+LL | let a = A;
+ | ^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:14:14
+ |
+LL | let ra = &A;
+ | ^^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:15:14
+ |
+LL | let xa = XA;
+ | ^^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:16:15
+ |
+LL | let xra = &XA;
+ | ^^^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
--- /dev/null
+// aux-build:extern-statics.rs
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
+extern crate extern_statics;
+use extern_statics::*;
+
+extern "C" {
+ static A: u8;
+}
+
+fn main() {
+ let a = A; //~ ERROR use of extern static is unsafe
+ let ra = &A; //~ ERROR use of extern static is unsafe
+ let xa = XA; //~ ERROR use of extern static is unsafe
+ let xra = &XA; //~ ERROR use of extern static is unsafe
+}
--- /dev/null
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:13:13
+ |
+LL | let a = A;
+ | ^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:14:15
+ |
+LL | let ra = &A;
+ | ^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:15:14
+ |
+LL | let xa = XA;
+ | ^^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/safe-extern-statics.rs:16:16
+ |
+LL | let xra = &XA;
+ | ^^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
--- /dev/null
+#![feature(thread_local)]
+
+#[thread_local]
+static A: u32 = 1;
+
+static B: u32 = A;
+//~^ ERROR thread-local statics cannot be accessed at compile-time
+
+static C: &u32 = &A;
+//~^ ERROR thread-local statics cannot be accessed at compile-time
+
+const D: u32 = A;
+//~^ ERROR thread-local statics cannot be accessed at compile-time
+
+const E: &u32 = &A;
+//~^ ERROR thread-local statics cannot be accessed at compile-time
+
+const fn f() -> u32 {
+ A
+ //~^ ERROR thread-local statics cannot be accessed at compile-time
+}
+
+fn main() {}
--- /dev/null
+error[E0625]: thread-local statics cannot be accessed at compile-time
+ --> $DIR/thread-local-in-ctfe.rs:6:17
+ |
+LL | static B: u32 = A;
+ | ^
+
+error[E0625]: thread-local statics cannot be accessed at compile-time
+ --> $DIR/thread-local-in-ctfe.rs:9:19
+ |
+LL | static C: &u32 = &A;
+ | ^
+
+error[E0625]: thread-local statics cannot be accessed at compile-time
+ --> $DIR/thread-local-in-ctfe.rs:12:16
+ |
+LL | const D: u32 = A;
+ | ^
+
+error[E0625]: thread-local statics cannot be accessed at compile-time
+ --> $DIR/thread-local-in-ctfe.rs:15:18
+ |
+LL | const E: &u32 = &A;
+ | ^
+
+error[E0625]: thread-local statics cannot be accessed at compile-time
+ --> $DIR/thread-local-in-ctfe.rs:19:5
+ |
+LL | A
+ | ^
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0625`.
--- /dev/null
+// build-pass
+// compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes
+
+// This test declares globals by the same name with different types, which
+// caused problems because Module::getOrInsertGlobal would return a Constant*
+// bitcast instead of a GlobalVariable* that could access linkage/visibility.
+// In alt builds with LLVM assertions this would fail:
+//
+// rustc: /checkout/src/llvm-project/llvm/include/llvm/Support/Casting.h:269:
+// typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = llvm::GlobalValue, Y = llvm::Value]:
+// Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
+//
+// In regular builds, the bad cast was UB, like "Invalid LLVMRustVisibility value!"
+
+pub mod before {
+ #[no_mangle]
+ pub static GLOBAL1: [u8; 1] = [1];
+}
+
+pub mod inner {
+ extern "C" {
+ pub static GLOBAL1: u8;
+ pub static GLOBAL2: u8;
+ }
+
+ pub fn call() {
+ drop(unsafe { (GLOBAL1, GLOBAL2) });
+ }
+}
+
+pub mod after {
+ #[no_mangle]
+ pub static GLOBAL2: [u8; 1] = [2];
+}
--- /dev/null
+// build-pass
+// compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes
+
+// This is a variant of issue-91050-1.rs -- see there for an explanation.
+
+pub mod before {
+ extern "C" {
+ pub static GLOBAL1: [u8; 1];
+ }
+
+ pub unsafe fn do_something_with_array() -> u8 {
+ GLOBAL1[0]
+ }
+}
+
+pub mod inner {
+ extern "C" {
+ pub static GLOBAL1: u8;
+ }
+
+ pub unsafe fn call() -> u8 {
+ GLOBAL1 + 42
+ }
+}
--- /dev/null
+// run-pass
+// edition:2021
+
+// regression test for https://github.com/rust-lang/rust/pull/85678
+
+#![feature(assert_matches)]
+
+use std::assert_matches::assert_matches;
+
+fn main() {
+ assert!(matches!((), ()));
+ assert_matches!((), ());
+}
--- /dev/null
+// run-pass
+
+use std::fmt::Debug;
+use std::cmp::{self, PartialOrd, Ordering};
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
+struct Foo {
+ n: u8,
+ name: &'static str
+}
+
+impl PartialOrd for Foo {
+ fn partial_cmp(&self, other: &Foo) -> Option<Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl Ord for Foo {
+ fn cmp(&self, other: &Foo) -> Ordering {
+ self.n.cmp(&other.n)
+ }
+}
+
+fn main() {
+ let a = Foo { n: 4, name: "a" };
+ let b = Foo { n: 4, name: "b" };
+ let c = Foo { n: 8, name: "c" };
+ let d = Foo { n: 8, name: "d" };
+ let e = Foo { n: 22, name: "e" };
+ let f = Foo { n: 22, name: "f" };
+
+ let data = [a, b, c, d, e, f];
+
+ // `min` should return the left when the values are equal
+ assert_eq!(data.iter().min(), Some(&a));
+ assert_eq!(data.iter().min_by_key(|a| a.n), Some(&a));
+ assert_eq!(cmp::min(a, b), a);
+ assert_eq!(cmp::min(b, a), b);
+
+ // `max` should return the right when the values are equal
+ assert_eq!(data.iter().max(), Some(&f));
+ assert_eq!(data.iter().max_by_key(|a| a.n), Some(&f));
+ assert_eq!(cmp::max(e, f), f);
+ assert_eq!(cmp::max(f, e), e);
+
+ let mut presorted = data.to_vec();
+ presorted.sort();
+ assert_stable(&presorted);
+
+ let mut presorted = data.to_vec();
+ presorted.sort_by(|a, b| a.cmp(b));
+ assert_stable(&presorted);
+
+ // Assert that sorted and min/max are the same
+ fn assert_stable<T: Ord + Debug>(presorted: &[T]) {
+ for slice in presorted.windows(2) {
+ let a = &slice[0];
+ let b = &slice[1];
+
+ assert_eq!(a, cmp::min(a, b));
+ assert_eq!(b, cmp::max(a, b));
+ }
+ }
+}
--- /dev/null
+use std::cell::{Cell, RefCell};
+use std::rc::{Rc, Weak};
+use std::sync::mpsc::{Receiver, Sender};
+
+fn test<T: Sync>() {}
+
+fn main() {
+ test::<Cell<i32>>();
+ //~^ ERROR `Cell<i32>` cannot be shared between threads safely [E0277]
+ test::<RefCell<i32>>();
+ //~^ ERROR `RefCell<i32>` cannot be shared between threads safely [E0277]
+
+ test::<Rc<i32>>();
+ //~^ ERROR `Rc<i32>` cannot be shared between threads safely [E0277]
+ test::<Weak<i32>>();
+ //~^ ERROR `std::rc::Weak<i32>` cannot be shared between threads safely [E0277]
+
+ test::<Receiver<i32>>();
+ //~^ ERROR `std::sync::mpsc::Receiver<i32>` cannot be shared between threads safely [E0277]
+ test::<Sender<i32>>();
+ //~^ ERROR `Sender<i32>` cannot be shared between threads safely [E0277]
+}
--- /dev/null
+error[E0277]: `Cell<i32>` cannot be shared between threads safely
+ --> $DIR/not-sync.rs:8:12
+ |
+LL | test::<Cell<i32>>();
+ | ^^^^^^^^^ `Cell<i32>` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `Cell<i32>`
+note: required by a bound in `test`
+ --> $DIR/not-sync.rs:5:12
+ |
+LL | fn test<T: Sync>() {}
+ | ^^^^ required by this bound in `test`
+
+error[E0277]: `RefCell<i32>` cannot be shared between threads safely
+ --> $DIR/not-sync.rs:10:12
+ |
+LL | test::<RefCell<i32>>();
+ | ^^^^^^^^^^^^ `RefCell<i32>` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `RefCell<i32>`
+note: required by a bound in `test`
+ --> $DIR/not-sync.rs:5:12
+ |
+LL | fn test<T: Sync>() {}
+ | ^^^^ required by this bound in `test`
+
+error[E0277]: `Rc<i32>` cannot be shared between threads safely
+ --> $DIR/not-sync.rs:13:12
+ |
+LL | test::<Rc<i32>>();
+ | ^^^^^^^ `Rc<i32>` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `Rc<i32>`
+note: required by a bound in `test`
+ --> $DIR/not-sync.rs:5:12
+ |
+LL | fn test<T: Sync>() {}
+ | ^^^^ required by this bound in `test`
+
+error[E0277]: `std::rc::Weak<i32>` cannot be shared between threads safely
+ --> $DIR/not-sync.rs:15:12
+ |
+LL | test::<Weak<i32>>();
+ | ^^^^^^^^^ `std::rc::Weak<i32>` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `std::rc::Weak<i32>`
+note: required by a bound in `test`
+ --> $DIR/not-sync.rs:5:12
+ |
+LL | fn test<T: Sync>() {}
+ | ^^^^ required by this bound in `test`
+
+error[E0277]: `std::sync::mpsc::Receiver<i32>` cannot be shared between threads safely
+ --> $DIR/not-sync.rs:18:12
+ |
+LL | test::<Receiver<i32>>();
+ | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<i32>` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `std::sync::mpsc::Receiver<i32>`
+note: required by a bound in `test`
+ --> $DIR/not-sync.rs:5:12
+ |
+LL | fn test<T: Sync>() {}
+ | ^^^^ required by this bound in `test`
+
+error[E0277]: `Sender<i32>` cannot be shared between threads safely
+ --> $DIR/not-sync.rs:20:12
+ |
+LL | test::<Sender<i32>>();
+ | ^^^^^^^^^^^ `Sender<i32>` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `Sender<i32>`
+note: required by a bound in `test`
+ --> $DIR/not-sync.rs:5:12
+ |
+LL | fn test<T: Sync>() {}
+ | ^^^^ required by this bound in `test`
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
--- /dev/null
+// run-pass
+// check raw fat pointer ops
+
+use std::mem;
+
+fn assert_inorder<T: PartialEq + PartialOrd>(a: &[T]) {
+ for i in 0..a.len() {
+ for j in 0..a.len() {
+ if i < j {
+ assert!(a[i] < a[j]);
+ assert!(a[i] <= a[j]);
+ assert!(!(a[i] == a[j]));
+ assert!(a[i] != a[j]);
+ assert!(!(a[i] >= a[j]));
+ assert!(!(a[i] > a[j]));
+ } else if i == j {
+ assert!(!(a[i] < a[j]));
+ assert!(a[i] <= a[j]);
+ assert!(a[i] == a[j]);
+ assert!(!(a[i] != a[j]));
+ assert!(a[i] >= a[j]);
+ assert!(!(a[i] > a[j]));
+ } else {
+ assert!(!(a[i] < a[j]));
+ assert!(!(a[i] <= a[j]));
+ assert!(!(a[i] == a[j]));
+ assert!(a[i] != a[j]);
+ assert!(a[i] >= a[j]);
+ assert!(a[i] > a[j]);
+ }
+ }
+ }
+}
+
+trait Foo { fn foo(&self) -> usize; }
+impl<T> Foo for T {
+ fn foo(&self) -> usize {
+ mem::size_of::<T>()
+ }
+}
+
+struct S<T:?Sized>(u32, T);
+
+fn main() {
+ let mut array = [0,1,2,3,4];
+ let mut array2 = [5,6,7,8,9];
+
+ // fat ptr comparison: addr then extra
+
+ // check ordering for arrays
+ let mut ptrs: Vec<*const [u8]> = vec![
+ &array[0..0], &array[0..1], &array, &array[1..]
+ ];
+
+ let array_addr = &array as *const [u8] as *const u8 as usize;
+ let array2_addr = &array2 as *const [u8] as *const u8 as usize;
+ if array2_addr < array_addr {
+ ptrs.insert(0, &array2);
+ } else {
+ ptrs.push(&array2);
+ }
+ assert_inorder(&ptrs);
+
+ // check ordering for mut arrays
+ let mut ptrs: Vec<*mut [u8]> = vec![
+ &mut array[0..0], &mut array[0..1], &mut array, &mut array[1..]
+ ];
+
+ let array_addr = &mut array as *mut [u8] as *mut u8 as usize;
+ let array2_addr = &mut array2 as *mut [u8] as *mut u8 as usize;
+ if array2_addr < array_addr {
+ ptrs.insert(0, &mut array2);
+ } else {
+ ptrs.push(&mut array2);
+ }
+ assert_inorder(&ptrs);
+
+ let mut u8_ = (0u8, 1u8);
+ let mut u32_ = (4u32, 5u32);
+
+ // check ordering for ptrs
+ let buf: &mut [*const dyn Foo] = &mut [
+ &u8_, &u8_.0,
+ &u32_, &u32_.0,
+ ];
+ buf.sort_by(|u,v| {
+ let u : [*const (); 2] = unsafe { mem::transmute(*u) };
+ let v : [*const (); 2] = unsafe { mem::transmute(*v) };
+ u.cmp(&v)
+ });
+ assert_inorder(buf);
+
+ // check ordering for mut ptrs
+ let buf: &mut [*mut dyn Foo] = &mut [
+ &mut u8_, &mut u8_.0,
+ &mut u32_, &mut u32_.0,
+ ];
+ buf.sort_by(|u,v| {
+ let u : [*const (); 2] = unsafe { mem::transmute(*u) };
+ let v : [*const (); 2] = unsafe { mem::transmute(*v) };
+ u.cmp(&v)
+ });
+ assert_inorder(buf);
+
+ // check ordering for structs containing arrays
+ let ss: (S<[u8; 2]>,
+ S<[u8; 3]>,
+ S<[u8; 2]>) = (
+ S(7, [8, 9]),
+ S(10, [11, 12, 13]),
+ S(4, [5, 6])
+ );
+ assert_inorder(&[
+ &ss.0 as *const S<[u8]>,
+ &ss.1 as *const S<[u8]>,
+ &ss.2 as *const S<[u8]>
+ ]);
+}
--- /dev/null
+// run-pass
+
+#![allow(stable_features)]
+#![feature(volatile)]
+use std::ptr::{read_volatile, write_volatile};
+
+fn main() {
+ let mut x: &'static str = "test";
+ unsafe {
+ let a = read_volatile(&x);
+ assert_eq!(a, "test");
+ write_volatile(&mut x, "foo");
+ assert_eq!(x, "foo");
+ }
+}
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
+note: required by a bound in `core::str::<impl str>::get`
+ --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+ |
+LL | pub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&I::Output> {
+ | ^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get`
error[E0277]: the type `str` cannot be indexed by `{integer}`
--> $DIR/str-idx.rs:5:29
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
+note: required by a bound in `core::str::<impl str>::get_unchecked`
+ --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+ |
+LL | pub unsafe fn get_unchecked<I: SliceIndex<str>>(&self, i: I) -> &I::Output {
+ | ^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get_unchecked`
error[E0277]: the type `str` cannot be indexed by `char`
--> $DIR/str-idx.rs:6:17
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
+note: required by a bound in `core::str::<impl str>::get_mut`
+ --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+ |
+LL | pub fn get_mut<I: SliceIndex<str>>(&mut self, i: I) -> Option<&mut I::Output> {
+ | ^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get_mut`
error[E0277]: the type `str` cannot be indexed by `{integer}`
--> $DIR/str-mut-idx.rs:11:25
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
+note: required by a bound in `core::str::<impl str>::get_unchecked_mut`
+ --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+ |
+LL | pub unsafe fn get_unchecked_mut<I: SliceIndex<str>>(&mut self, i: I) -> &mut I::Output {
+ | ^^^^^^^^^^^^^^^ required by this bound in `core::str::<impl str>::get_unchecked_mut`
error[E0277]: the type `str` cannot be indexed by `char`
--> $DIR/str-mut-idx.rs:13:5
LL | let s = A { a: NoClone };
| ^ the trait `Clone` is not implemented for `NoClone`
|
-note: required by `S`
- --> $DIR/struct-path-alias-bounds.rs:3:1
+note: required by a bound in `S`
+ --> $DIR/struct-path-alias-bounds.rs:3:13
|
LL | struct S<T: Clone> { a: T }
- | ^^^^^^^^^^^^^^^^^^
+ | ^^^^^ required by this bound in `S`
error: aborting due to previous error
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:16:17
- |
-LL | fn bar<'a, T>() where T: 'a {}
- | --------------------------- fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>} defined here
-...
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
- | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
-help: use parentheses to call this function
- |
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
- | ++
-
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:25:17
- |
-LL | fn bar<'a, T>() where T: 'a {}
- | --------------------------- fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>} defined here
-...
-LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
- | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
-help: use parentheses to call this function
- |
-LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
- | ++
-
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:33:17
- |
-LL | fn baz() {}
- | -------- fn() {<i8 as Foo<'static, 'static, u8>>::baz} defined here
-...
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
- | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
-help: use parentheses to call this function
- |
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
- | ++
-
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:41:17
- |
-LL | fn foo<'z>() where &'z (): Sized {
- | -------------------------------- fn() {foo::<'static>} defined here
-...
-LL | let x: () = foo::<'static>;
- | -- ^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {foo::<'static>}`
-help: use parentheses to call this function
- |
-LL | let x: () = foo::<'static>();
- | ++
-
-error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/substs-ppaux.rs:49:5
- |
-LL | <str as Foo<u8>>::bar;
- | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `str`
-note: required because of the requirements on the impl of `Foo<'_, '_, u8>` for `str`
- --> $DIR/substs-ppaux.rs:11:17
- |
-LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
- | ^^^^^^^^^^^^^^ ^
-note: required by a bound in `Foo::bar`
- --> $DIR/substs-ppaux.rs:7:30
- |
-LL | fn bar<'a, T>() where T: 'a {}
- | ^^ required by this bound in `Foo::bar`
-
-error: aborting due to 5 previous errors
-
-Some errors have detailed explanations: E0277, E0308.
-For more information about an error, try `rustc --explain E0277`.
+++ /dev/null
-//
-// revisions: verbose normal
-//
-//[verbose] compile-flags: -Z verbose
-
-trait Foo<'b, 'c, S=u32> {
- fn bar<'a, T>() where T: 'a {}
- fn baz() {}
-}
-
-impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
-
-fn main() {}
-
-fn foo<'z>() where &'z (): Sized {
- let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
- //[verbose]~^ ERROR mismatched types
- //[verbose]~| expected unit type `()`
- //[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
- //[normal]~^^^^ ERROR mismatched types
- //[normal]~| expected unit type `()`
- //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
-
-
- let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
- //[verbose]~^ ERROR mismatched types
- //[verbose]~| expected unit type `()`
- //[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
- //[normal]~^^^^ ERROR mismatched types
- //[normal]~| expected unit type `()`
- //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
-
- let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
- //[verbose]~^ ERROR mismatched types
- //[verbose]~| expected unit type `()`
- //[verbose]~| found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
- //[normal]~^^^^ ERROR mismatched types
- //[normal]~| expected unit type `()`
- //[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
-
- let x: () = foo::<'static>;
- //[verbose]~^ ERROR mismatched types
- //[verbose]~| expected unit type `()`
- //[verbose]~| found fn item `fn() {foo::<ReStatic>}`
- //[normal]~^^^^ ERROR mismatched types
- //[normal]~| expected unit type `()`
- //[normal]~| found fn item `fn() {foo::<'static>}`
-
- <str as Foo<u8>>::bar;
- //[verbose]~^ ERROR the size for values of type
- //[normal]~^^ ERROR the size for values of type
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:16:17
- |
-LL | fn bar<'a, T>() where T: 'a {}
- | --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>} defined here
-...
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
- | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
-help: use parentheses to call this function
- |
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
- | ++
-
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:25:17
- |
-LL | fn bar<'a, T>() where T: 'a {}
- | --------------------------- fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>} defined here
-...
-LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
- | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {<i8 as Foo<ReStatic, ReStatic>>::bar::<ReStatic, char>}`
-help: use parentheses to call this function
- |
-LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
- | ++
-
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:33:17
- |
-LL | fn baz() {}
- | -------- fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz} defined here
-...
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
- | -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
-help: use parentheses to call this function
- |
-LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
- | ++
-
-error[E0308]: mismatched types
- --> $DIR/substs-ppaux.rs:41:17
- |
-LL | fn foo<'z>() where &'z (): Sized {
- | -------------------------------- fn() {foo::<ReStatic>} defined here
-...
-LL | let x: () = foo::<'static>;
- | -- ^^^^^^^^^^^^^^ expected `()`, found fn item
- | |
- | expected due to this
- |
- = note: expected unit type `()`
- found fn item `fn() {foo::<ReStatic>}`
-help: use parentheses to call this function
- |
-LL | let x: () = foo::<'static>();
- | ++
-
-error[E0277]: the size for values of type `str` cannot be known at compilation time
- --> $DIR/substs-ppaux.rs:49:5
- |
-LL | <str as Foo<u8>>::bar;
- | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `str`
-note: required because of the requirements on the impl of `Foo<'_#0r, '_#1r, u8>` for `str`
- --> $DIR/substs-ppaux.rs:11:17
- |
-LL | impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
- | ^^^^^^^^^^^^^^ ^
-note: required by a bound in `Foo::bar`
- --> $DIR/substs-ppaux.rs:7:30
- |
-LL | fn bar<'a, T>() where T: 'a {}
- | ^^ required by this bound in `Foo::bar`
-
-error: aborting due to 5 previous errors
-
-Some errors have detailed explanations: E0277, E0308.
-For more information about an error, try `rustc --explain E0277`.
+++ /dev/null
-#![feature(rustc_attrs)]
-
-#[rustc_dummy = 1usize] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1u8] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1u16] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1u32] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1u64] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1isize] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1i8] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1i16] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1i32] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1i64] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes
-#[rustc_dummy = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes
-fn main() {}
+++ /dev/null
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:3:17
- |
-LL | #[rustc_dummy = 1usize]
- | ^^^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:4:17
- |
-LL | #[rustc_dummy = 1u8]
- | ^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:5:17
- |
-LL | #[rustc_dummy = 1u16]
- | ^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:6:17
- |
-LL | #[rustc_dummy = 1u32]
- | ^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:7:17
- |
-LL | #[rustc_dummy = 1u64]
- | ^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:8:17
- |
-LL | #[rustc_dummy = 1isize]
- | ^^^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:9:17
- |
-LL | #[rustc_dummy = 1i8]
- | ^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:10:17
- |
-LL | #[rustc_dummy = 1i16]
- | ^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:11:17
- |
-LL | #[rustc_dummy = 1i32]
- | ^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:12:17
- |
-LL | #[rustc_dummy = 1i64]
- | ^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:13:17
- |
-LL | #[rustc_dummy = 1.0f32]
- | ^^^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: suffixed literals are not allowed in attributes
- --> $DIR/suffixed-literal-meta.rs:14:17
- |
-LL | #[rustc_dummy = 1.0f64]
- | ^^^^^^
- |
- = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: aborting due to 12 previous errors
-
-error[E0277]: `fn() -> impl Future {foo}` is not a future
+error[E0277]: `fn() -> impl Future<Output = ()> {foo}` is not a future
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:10:9
|
LL | async fn foo() {}
| --- consider calling this function
...
LL | bar(foo);
- | --- ^^^ `fn() -> impl Future {foo}` is not a future
+ | --- ^^^ `fn() -> impl Future<Output = ()> {foo}` is not a future
| |
| required by a bound introduced by this call
|
- = help: the trait `Future` is not implemented for `fn() -> impl Future {foo}`
+ = help: the trait `Future` is not implemented for `fn() -> impl Future<Output = ()> {foo}`
note: required by a bound in `bar`
--> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16
|
Ty::List(elem) => foo(elem),
//~^ ERROR mismatched types
//~| HELP try dereferencing the `Box`
- //~| HELP try using a variant of the expected enum
+ //~| HELP try wrapping
}
}
|
LL | Ty::List(elem) => foo(*elem),
| +
-help: try using a variant of the expected enum
+help: try wrapping the expression in `Ty::List`
|
LL | Ty::List(elem) => foo(Ty::List(elem)),
- | ~~~~~~~~~~~~~~
+ | +++++++++ +
error: aborting due to previous error
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
|
= note: consider using `Box::pin`
-note: required by `Pin::<P>::new`
+note: required by a bound in `Pin::<P>::new`
--> $SRC_DIR/core/src/pin.rs:LL:COL
|
-LL | pub const fn new(pointer: P) -> Pin<P> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<P: Deref<Target: Unpin>> Pin<P> {
+ | ^^^^^ required by this bound in `Pin::<P>::new`
error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
--> $DIR/expected-boxed-future-isnt-pinned.rs:24:5
| ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
|
= note: consider using `Box::pin`
-note: required by `Pin::<P>::new`
+note: required by a bound in `Pin::<P>::new`
--> $SRC_DIR/core/src/pin.rs:LL:COL
|
-LL | pub const fn new(pointer: P) -> Pin<P> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<P: Deref<Target: Unpin>> Pin<P> {
+ | ^^^^^ required by this bound in `Pin::<P>::new`
error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:28:5
|
= note: the trait bound `String: Pattern<'_>` is not satisfied
= note: required because of the requirements on the impl of `Pattern<'_>` for `String`
+note: required by a bound in `core::str::<impl str>::find`
+ --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+ |
+LL | pub fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize> {
+ | ^^^^^^^^^^^ required by this bound in `core::str::<impl str>::find`
help: consider borrowing here
|
LL | println!("{:?}", line.find(&pattern));
--> $DIR/issue-72766.rs:14:5
|
LL | SadGirl {}.call()?;
- | ^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `impl Future`
+ | ^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = Result<(), ()>>`
|
- = help: the trait `Try` is not implemented for `impl Future`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: the trait `Try` is not implemented for `impl Future<Output = Result<(), ()>>`
help: consider `await`ing on the `Future`
|
LL | SadGirl {}.call().await?;
LL | pub async fn answer_str(&self, _s: &str) -> Test {
| ^^^^ checked the `Output` of this `async fn`, found opaque type
= note: expected type `()`
- found opaque type `impl Future`
+ found opaque type `impl Future<Output = Test>`
error: aborting due to previous error
| |
| required by a bound introduced by this call
|
-note: required by `Other::<'a, G>::new`
- --> $DIR/issue-84973.rs:27:5
+note: required by a bound in `Other::<'a, G>::new`
+ --> $DIR/issue-84973.rs:25:8
|
+LL | G: SomeTrait,
+ | ^^^^^^^^^ required by this bound in `Other::<'a, G>::new`
+LL | {
LL | pub fn new(g: G) -> Self {
- | ^^^^^^^^^^^^^^^^^^^^^^^^
+ | --- required by a bound in this
help: consider borrowing here
|
LL | let o = Other::new(&f);
--- /dev/null
+fn main() {
+ println!("{}", (3.).recip()); //~ERROR
+}
--- /dev/null
+error[E0689]: can't call method `recip` on ambiguous numeric type `{float}`
+ --> $DIR/issue-90974.rs:2:25
+ |
+LL | println!("{}", (3.).recip());
+ | ^^^^^
+ |
+help: you must specify a concrete type for this numeric value, like `f32`
+ |
+LL | println!("{}", (3_f32).recip());
+ | ~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0689`.
|
LL | fn func<T: Test>(foo: &Foo, t: T) {
| ^^^
-note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds
+note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds...
--> $DIR/missing-lifetimes-in-signature-2.rs:20:9
|
LL | foo.bar(move |_| {
| ^^^
+note: ...that is required by this bound
+ --> $DIR/missing-lifetimes-in-signature-2.rs:11:12
+ |
+LL | F: 'a,
+ | ^^
error: aborting due to previous error
//~| HELP consider `await`ing on both `Future`s
false => async_dummy2(), //~ ERROR `match` arms have incompatible types
//~^ NOTE expected opaque type, found a different opaque type
- //~| NOTE expected type `impl Future`
+ //~| NOTE expected type `impl Future<Output = ()>`
//~| NOTE distinct uses of `impl Trait` result in different opaque types
};
}
LL | async fn async_dummy() {}
| ^ checked the `Output` of this `async fn`, found opaque type
= note: expected type `()`
- found opaque type `impl Future`
+ found opaque type `impl Future<Output = ()>`
help: consider `await`ing on the `Future`
|
LL | false => async_dummy().await,
LL | async fn async_dummy2() {}
| ^ checked the `Output` of this `async fn`, found opaque type
= note: expected type `()`
- found opaque type `impl Future`
+ found opaque type `impl Future<Output = ()>`
help: consider `await`ing on the `Future`
|
LL | false => async_dummy2().await,
LL | let _ = match true {
| _____________-
LL | | true => async_dummy(),
- | | ------------- this is found to be of type `impl Future`
+ | | ------------- this is found to be of type `impl Future<Output = ()>`
LL | |
LL | | false => async_dummy2(),
| | ^^^^^^^^^^^^^^ expected opaque type, found a different opaque type
|
LL | async fn async_dummy2() {}
| ^ checked the `Output` of this `async fn`, found opaque type
- = note: expected type `impl Future` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>)
- found opaque type `impl Future` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:19:25>)
+ = note: expected type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>)
+ found opaque type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:19:25>)
= note: distinct uses of `impl Trait` result in different opaque types
help: consider `await`ing on both `Future`s
|
+++ /dev/null
-// run-rustfix
-
-pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) {
- let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]`
-}
-
-fn main() {}
+++ /dev/null
-// run-rustfix
-
-pub fn foo<T>(s: &[T], t: &[T]) {
- let _ = s == t; //~ ERROR binary operation `==` cannot be applied to type `&[T]`
-}
-
-fn main() {}
+++ /dev/null
-error[E0369]: binary operation `==` cannot be applied to type `&[T]`
- --> $DIR/missing-trait-bound-for-op.rs:4:15
- |
-LL | let _ = s == t;
- | - ^^ - &[T]
- | |
- | &[T]
- |
-help: consider restricting type parameter `T`
- |
-LL | pub fn foo<T: std::cmp::PartialEq>(s: &[T], t: &[T]) {
- | +++++++++++++++++++++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0369`.
+++ /dev/null
-#[derive(Default, PartialEq)]
-struct Foo<T> {
- bar: Box<[T]>,
-}
-
-trait Bar {
- fn foo(&self) {}
-}
-
-impl<T: Default + Bar> Bar for Foo<T> {}
-
-impl<T> Foo<T> {
- fn bar(&self) {
- self.foo();
- //~^ ERROR the method
- }
-}
-
-struct Fin<T> where T: Bar {
- bar: Box<[T]>,
-}
-
-impl<T: Default + Bar> Bar for Fin<T> {}
-
-impl<T: Bar> Fin<T> {
- fn bar(&self) {
- self.foo();
- //~^ ERROR the method
- }
-}
-fn main() {}
+++ /dev/null
-error[E0599]: the method `foo` exists for reference `&Foo<T>`, but its trait bounds were not satisfied
- --> $DIR/missing-trait-bounds-for-method-call.rs:14:14
- |
-LL | struct Foo<T> {
- | ------------- doesn't satisfy `Foo<T>: Bar`
-...
-LL | self.foo();
- | ^^^ method cannot be called on `&Foo<T>` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `T: Default`
- which is required by `Foo<T>: Bar`
- `T: Bar`
- which is required by `Foo<T>: Bar`
-help: consider restricting the type parameters to satisfy the trait bounds
- |
-LL | struct Foo<T> where T: Bar, T: Default {
- | ++++++++++++++++++++++++
-
-error[E0599]: the method `foo` exists for reference `&Fin<T>`, but its trait bounds were not satisfied
- --> $DIR/missing-trait-bounds-for-method-call.rs:27:14
- |
-LL | struct Fin<T> where T: Bar {
- | -------------------------- doesn't satisfy `Fin<T>: Bar`
-...
-LL | self.foo();
- | ^^^ method cannot be called on `&Fin<T>` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `T: Default`
- which is required by `Fin<T>: Bar`
-help: consider restricting the type parameter to satisfy the trait bound
- |
-LL | struct Fin<T> where T: Bar, T: Default {
- | ++++++++++++
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0599`.
| required by a bound introduced by this call
|
= note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write`
-note: required by `BufWriter::<W>::new`
+note: required by a bound in `BufWriter::<W>::new`
--> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
|
-LL | pub fn new(inner: W) -> BufWriter<W> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<W: Write> BufWriter<W> {
+ | ^^^^^ required by this bound in `BufWriter::<W>::new`
error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
--> $DIR/mut-borrow-needed-by-trait.rs:17:14
LL | | }.await
| |_____- `if` and `else` have incompatible types
|
- = note: expected type `impl Future` (opaque type at <$DIR/opaque-type-error.rs:8:19>)
- found opaque type `impl Future` (opaque type at <$DIR/opaque-type-error.rs:12:19>)
+ = note: expected type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:8:19>)
+ found opaque type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:12:19>)
= note: distinct uses of `impl Trait` result in different opaque types
help: consider `await`ing on both `Future`s
|
|
= note: the trait bound `[i32]: IntoIterator` is not satisfied
= note: required because of the requirements on the impl of `IntoIterator` for `[i32]`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider borrowing here
|
LL | for _ in &v[1..] {
|
= note: the trait bound `[i32]: IntoIterator` is not satisfied
= note: required because of the requirements on the impl of `IntoIterator` for `[i32]`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider borrowing here
|
LL | for _ in &v[1..] {
|
= note: the trait bound `[K]: IntoIterator` is not satisfied
= note: required because of the requirements on the impl of `IntoIterator` for `[K]`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider borrowing here
|
LL | for i2 in &v2[1..] {
|
= note: the trait bound `[K]: IntoIterator` is not satisfied
= note: required because of the requirements on the impl of `IntoIterator` for `[K]`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider borrowing here
|
LL | for i2 in &v2[1..] {
| |
| required by a bound introduced by this call
|
-note: required by `BufReader::<R>::new`
+note: required by a bound in `BufReader::<R>::new`
--> $SRC_DIR/std/src/io/buffered/bufreader.rs:LL:COL
|
-LL | pub fn new(inner: R) -> BufReader<R> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<R: Read> BufReader<R> {
+ | ^^^^ required by this bound in `BufReader::<R>::new`
help: consider removing the leading `&`-reference
|
LL - let mut stream_reader = BufReader::new(&stream);
--> $DIR/suggest-full-enum-variant-for-local-module.rs:9:28
|
LL | let _: option::O<()> = ();
- | ------------- ^^
- | | |
- | | expected enum `O`, found `()`
- | | help: try using a variant of the expected enum: `option::O::Some(())`
+ | ------------- ^^ expected enum `O`, found `()`
+ | |
| expected due to this
|
= note: expected enum `O<()>`
found unit type `()`
+help: try wrapping the expression in `option::O::Some`
+ |
+LL | let _: option::O<()> = option::O::Some(());
+ | ++++++++++++++++ +
error: aborting due to previous error
|
= help: the trait `Iterator` is not implemented for `&Enumerate<std::slice::Iter<'_, {integer}>>`
= note: required because of the requirements on the impl of `IntoIterator` for `&Enumerate<std::slice::Iter<'_, {integer}>>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
|
= help: the trait `Iterator` is not implemented for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>`
= note: required because of the requirements on the impl of `IntoIterator` for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
|
= help: the trait `Iterator` is not implemented for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>`
= note: required because of the requirements on the impl of `IntoIterator` for `&&&&&Enumerate<std::slice::Iter<'_, {integer}>>`
-note: required by `into_iter`
- --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- |
-LL | fn into_iter(self) -> Self::IntoIter;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
+++ /dev/null
-use std::marker::Send;
-
-struct TestType;
-
-trait TestTrait {}
-
-impl !Send for TestType {}
-//~^ ERROR negative trait bounds
-
-fn main() {}
+++ /dev/null
-error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now
- --> $DIR/syntax-trait-polarity-feature-gate.rs:7:6
- |
-LL | impl !Send for TestType {}
- | ^^^^^
- |
- = note: see issue #68318 <https://github.com/rust-lang/rust/issues/68318> for more information
- = help: add `#![feature(negative_impls)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
+++ /dev/null
-#![feature(rustc_attrs)]
-
-fn func<#[rustc_synthetic] T>(_: T) {}
-
-struct Foo;
-
-impl Foo {
- pub fn func<#[rustc_synthetic] T>(_: T) {}
-}
-
-struct Bar<S> {
- t: S
-}
-
-impl<S> Bar<S> {
- pub fn func<#[rustc_synthetic] T>(_: T) {}
-}
-
-fn main() {
- func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
- func(42); // Ok
-
- Foo::func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
- Foo::func(42); // Ok
-
- Bar::<i8>::func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
- Bar::<i8>::func(42); // Ok
-}
+++ /dev/null
-error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
- --> $DIR/synthetic-param.rs:20:12
- |
-LL | func::<u8>(42);
- | ^^ explicit generic argument not allowed
- |
- = note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
- = help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
-
-error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
- --> $DIR/synthetic-param.rs:23:17
- |
-LL | Foo::func::<u8>(42);
- | ^^ explicit generic argument not allowed
- |
- = note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
- = help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
-
-error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
- --> $DIR/synthetic-param.rs:26:23
- |
-LL | Bar::<i8>::func::<u8>(42);
- | ^^ explicit generic argument not allowed
- |
- = note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
- = help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0632`.
+++ /dev/null
-// run-pass
-
-pub fn main() { assert!((even(42))); assert!((odd(45))); }
-
-fn even(n: isize) -> bool { if n == 0 { return true; } else { return odd(n - 1); } }
-
-fn odd(n: isize) -> bool { if n == 0 { return false; } else { return even(n - 1); } }
+++ /dev/null
-// run-pass
-// ignore-android needs extra network permissions
-// ignore-emscripten no threads or sockets support
-// ignore-netbsd system ulimit (Too many open files)
-// ignore-openbsd system ulimit (Too many open files)
-
-use std::io::prelude::*;
-use std::net::{TcpListener, TcpStream};
-use std::process;
-use std::sync::mpsc::channel;
-use std::time::Duration;
-use std::thread::{self, Builder};
-
-const TARGET_CNT: usize = 200;
-
-fn main() {
- // This test has a chance to time out, try to not let it time out
- thread::spawn(move|| -> () {
- thread::sleep(Duration::from_secs(30));
- process::exit(1);
- });
-
- let listener = TcpListener::bind("127.0.0.1:0").unwrap();
- let addr = listener.local_addr().unwrap();
- thread::spawn(move || -> () {
- loop {
- let mut stream = match listener.accept() {
- Ok(stream) => stream.0,
- Err(_) => continue,
- };
- let _ = stream.read(&mut [0]);
- let _ = stream.write(&[2]);
- }
- });
-
- let (tx, rx) = channel();
-
- let mut spawned_cnt = 0;
- for _ in 0..TARGET_CNT {
- let tx = tx.clone();
- let res = Builder::new().stack_size(64 * 1024).spawn(move|| {
- match TcpStream::connect(addr) {
- Ok(mut stream) => {
- let _ = stream.write(&[1]);
- let _ = stream.read(&mut [0]);
- },
- Err(..) => {}
- }
- tx.send(()).unwrap();
- });
- if let Ok(_) = res {
- spawned_cnt += 1;
- };
- }
-
- // Wait for all clients to exit, but don't wait for the server to exit. The
- // server just runs infinitely.
- drop(tx);
- for _ in 0..spawned_cnt {
- rx.recv().unwrap();
- }
- assert_eq!(spawned_cnt, TARGET_CNT);
- process::exit(0);
-}
+++ /dev/null
-#![feature(thread_local)]
-
-#[thread_local]
-static A: u32 = 1;
-
-static B: u32 = A;
-//~^ ERROR thread-local statics cannot be accessed at compile-time
-
-static C: &u32 = &A;
-//~^ ERROR thread-local statics cannot be accessed at compile-time
-
-const D: u32 = A;
-//~^ ERROR thread-local statics cannot be accessed at compile-time
-
-const E: &u32 = &A;
-//~^ ERROR thread-local statics cannot be accessed at compile-time
-
-const fn f() -> u32 {
- A
- //~^ ERROR thread-local statics cannot be accessed at compile-time
-}
-
-fn main() {}
+++ /dev/null
-error[E0625]: thread-local statics cannot be accessed at compile-time
- --> $DIR/thread-local-in-ctfe.rs:6:17
- |
-LL | static B: u32 = A;
- | ^
-
-error[E0625]: thread-local statics cannot be accessed at compile-time
- --> $DIR/thread-local-in-ctfe.rs:9:19
- |
-LL | static C: &u32 = &A;
- | ^
-
-error[E0625]: thread-local statics cannot be accessed at compile-time
- --> $DIR/thread-local-in-ctfe.rs:12:16
- |
-LL | const D: u32 = A;
- | ^
-
-error[E0625]: thread-local statics cannot be accessed at compile-time
- --> $DIR/thread-local-in-ctfe.rs:15:18
- |
-LL | const E: &u32 = &A;
- | ^
-
-error[E0625]: thread-local statics cannot be accessed at compile-time
- --> $DIR/thread-local-in-ctfe.rs:19:5
- |
-LL | A
- | ^
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0625`.
+++ /dev/null
-// run-pass
-#![no_std]
-
-extern crate std;
-
-std::thread_local!(static A: usize = 30);
-
-fn main() {
-}
--- /dev/null
+// run-pass
+
+#![allow(unused_must_use)]
+// ignore-emscripten no threads support
+
+use std::thread;
+
+struct Pair {
+ a: isize,
+ b: isize
+}
+
+pub fn main() {
+ let z: Box<_> = Box::new(Pair { a : 10, b : 12});
+
+ thread::spawn(move|| {
+ assert_eq!(z.a, 10);
+ assert_eq!(z.b, 12);
+ }).join();
+}
--- /dev/null
+// run-pass
+// ignore-android needs extra network permissions
+// ignore-emscripten no threads or sockets support
+// ignore-netbsd system ulimit (Too many open files)
+// ignore-openbsd system ulimit (Too many open files)
+
+use std::io::prelude::*;
+use std::net::{TcpListener, TcpStream};
+use std::process;
+use std::sync::mpsc::channel;
+use std::time::Duration;
+use std::thread::{self, Builder};
+
+const TARGET_CNT: usize = 200;
+
+fn main() {
+ // This test has a chance to time out, try to not let it time out
+ thread::spawn(move|| -> () {
+ thread::sleep(Duration::from_secs(30));
+ process::exit(1);
+ });
+
+ let listener = TcpListener::bind("127.0.0.1:0").unwrap();
+ let addr = listener.local_addr().unwrap();
+ thread::spawn(move || -> () {
+ loop {
+ let mut stream = match listener.accept() {
+ Ok(stream) => stream.0,
+ Err(_) => continue,
+ };
+ let _ = stream.read(&mut [0]);
+ let _ = stream.write(&[2]);
+ }
+ });
+
+ let (tx, rx) = channel();
+
+ let mut spawned_cnt = 0;
+ for _ in 0..TARGET_CNT {
+ let tx = tx.clone();
+ let res = Builder::new().stack_size(64 * 1024).spawn(move|| {
+ match TcpStream::connect(addr) {
+ Ok(mut stream) => {
+ let _ = stream.write(&[1]);
+ let _ = stream.read(&mut [0]);
+ },
+ Err(..) => {}
+ }
+ tx.send(()).unwrap();
+ });
+ if let Ok(_) = res {
+ spawned_cnt += 1;
+ };
+ }
+
+ // Wait for all clients to exit, but don't wait for the server to exit. The
+ // server just runs infinitely.
+ drop(tx);
+ for _ in 0..spawned_cnt {
+ rx.recv().unwrap();
+ }
+ assert_eq!(spawned_cnt, TARGET_CNT);
+ process::exit(0);
+}
--- /dev/null
+// run-pass
+
+#![allow(non_camel_case_types)]
+#![allow(dead_code)]
+
+struct pair<A,B> {
+ a: A, b: B
+}
+
+trait Invokable<A> {
+ fn f(&self) -> (A, u16);
+}
+
+struct Invoker<A> {
+ a: A,
+ b: u16,
+}
+
+impl<A:Clone> Invokable<A> for Invoker<A> {
+ fn f(&self) -> (A, u16) {
+ (self.a.clone(), self.b)
+ }
+}
+
+fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
+ Box::new(Invoker {
+ a: a,
+ b: b,
+ }) as Box<dyn Invokable<A>+'static>
+}
+
+pub fn main() {
+ let (a, b) = f(22_u64, 44u16).f();
+ println!("a={} b={}", a, b);
+ assert_eq!(a, 22u64);
+ assert_eq!(b, 44u16);
+}
LL | 1.bar::<T>();
| ^^^ `T` cannot be sent between threads safely
|
+note: required by a bound in `Bar::bar`
+ --> $DIR/bad-method-typaram-kind.rs:6:14
+ |
+LL | fn bar<T:Send>(&self);
+ | ^^^^ required by this bound in `Bar::bar`
help: consider further restricting this bound
|
LL | fn foo<T:'static + std::marker::Send>() {
| ^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Trait`
-note: required by `Vec::<T>::new`
+note: required by a bound in `Vec::<T>::new`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
-LL | pub const fn new() -> Self {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<T> Vec<T> {
+ | ^ required by this bound in `Vec::<T>::new`
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
--> $DIR/bad-sized.rs:4:37
LL | let foo = Foo {
| ^^^ the trait `Trait` is not implemented for `{integer}`
|
-note: required by `Foo`
- --> $DIR/on-structs-and-enums-locals.rs:5:1
+note: required by a bound in `Foo`
+ --> $DIR/on-structs-and-enums-locals.rs:5:14
|
LL | struct Foo<T:Trait> {
- | ^^^^^^^^^^^^^^^^^^^
+ | ^^^^^ required by this bound in `Foo`
error: aborting due to 2 previous errors
LL | let foo = Foo {
| ^^^ the trait `Trait` is not implemented for `{integer}`
|
-note: required by `Foo`
- --> $DIR/auxiliary/on_structs_and_enums_xc.rs:5:1
+note: required by a bound in `Foo`
+ --> $DIR/auxiliary/on_structs_and_enums_xc.rs:5:18
|
LL | pub struct Foo<T:Trait> {
- | ^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^ required by this bound in `Foo`
error: aborting due to 2 previous errors
--- /dev/null
+// run-pass
+// Regression test for #15477. This test just needs to compile.
+
+// pretty-expanded FIXME #23616
+
+trait Chromosome<X: Chromosome<i32>> {
+}
+
+impl Chromosome<i32> for i32 { }
+
+fn main() { }
--- /dev/null
+// run-pass
+
+#![allow(non_camel_case_types)]
+#![allow(dead_code)]
+// pretty-expanded FIXME #23616
+
+trait thing<A> {
+ fn foo(&self) -> Option<A>;
+}
+impl<A> thing<A> for isize {
+ fn foo(&self) -> Option<A> { None }
+}
+fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() }
+
+struct A { a: isize }
+
+pub fn main() {
+ let _x: Option<f64> = foo_func(0);
+}
|
LL | <dyn CompareToInts>::same_as(c, 22)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
- |
-note: required by `CompareTo::same_as`
- --> $DIR/repeated-supertrait-ambig.rs:9:5
- |
-LL | fn same_as(&self, t: T) -> bool;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `C: CompareTo<i32>` is not satisfied
--> $DIR/repeated-supertrait-ambig.rs:38:5
LL | CompareTo::same_as(c, 22)
| ^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `C`
|
-note: required by `CompareTo::same_as`
- --> $DIR/repeated-supertrait-ambig.rs:9:5
- |
-LL | fn same_as(&self, t: T) -> bool;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider further restricting this bound
|
LL | fn with_ufcs2<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool {
| ^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Foo`
|
= note: required because of the requirements on the impl of `Clone` for `Vec<Foo>`
-note: required by `clone`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | fn clone(&self) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
- impl Borrow<str> for String;
- impl<T> Borrow<T> for T
where T: ?Sized;
+note: required by a bound in `HashMap::<K, V, S>::get`
+ --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
+ |
+LL | K: Borrow<Q>,
+ | ^^^^^^^^^ required by this bound in `HashMap::<K, V, S>::get`
+help: consider specifying the type argument in the function call
+ |
+LL | opts.get::<Q>(opt.as_ref());
+ | +++++
error[E0283]: type annotations needed
--> $DIR/issue-77982.rs:8:18
- impl From<bool> for u32;
- impl From<char> for u32;
and 3 more
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed for `Box<T>`
--> $DIR/issue-77982.rs:36:16
= help: the following implementations were found:
<&T as Clone>
= note: `Clone` is implemented for `&T`, but not for `&mut T`
-note: required by `clone`
- --> $SRC_DIR/core/src/clone.rs:LL:COL
- |
-LL | fn clone(&self) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
| ^^^^^^^^^^^^^ cannot infer type for type parameter `T`
|
= note: cannot satisfy `T: FnMut<(&'a (),)>`
-note: required by a bound in `FnMut`
- --> $SRC_DIR/core/src/ops/function.rs:LL:COL
- |
-LL | / pub trait FnMut<Args>: FnOnce<Args> {
-LL | | /// Performs the call operation.
-LL | | #[unstable(feature = "fn_traits", issue = "29625")]
-LL | | extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
-LL | | }
- | |_^ required by this bound in `FnMut`
error: aborting due to previous error
--- /dev/null
+use std::collections::HashMap;
+
+
+
+trait Map<K, V>
+{
+ fn get(&self, k: K) -> V { panic!() }
+}
+
+impl<K, V> Map<K, V> for HashMap<K, V> {}
+
+// Test that trait types printed in error msgs include the type arguments.
+
+fn main() {
+ let x: Box<HashMap<isize, isize>> = HashMap::new().into();
+ let x: Box<dyn Map<isize, isize>> = x;
+ let y: Box<dyn Map<usize, isize>> = Box::new(x);
+ //~^ ERROR `Box<dyn Map<isize, isize>>: Map<usize, isize>` is not satisfied
+}
--- /dev/null
+error[E0277]: the trait bound `Box<dyn Map<isize, isize>>: Map<usize, isize>` is not satisfied
+ --> $DIR/map-types.rs:17:41
+ |
+LL | let y: Box<dyn Map<usize, isize>> = Box::new(x);
+ | ^^^^^^^^^^^ the trait `Map<usize, isize>` is not implemented for `Box<dyn Map<isize, isize>>`
+ |
+ = note: required for the cast to the object type `dyn Map<usize, isize>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
| required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `dummy::TestType`
-note: required by `Outer`
- --> $DIR/negated-auto-traits-error.rs:10:1
+note: required by a bound in `Outer`
+ --> $DIR/negated-auto-traits-error.rs:10:17
|
LL | struct Outer<T: Send>(T);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^ required by this bound in `Outer`
error[E0277]: `dummy::TestType` cannot be sent between threads safely
--> $DIR/negated-auto-traits-error.rs:23:5
--- /dev/null
+#![feature(negative_impls)]
+
+use std::marker::Send;
+
+struct Foo {
+ a: isize,
+}
+
+impl !Send for Foo {}
+
+fn bar<T: Send>(_: T) {}
+
+fn main() {
+ let x = Foo { a: 5 };
+ bar(x);
+ //~^ ERROR `Foo` cannot be sent between threads safely
+}
--- /dev/null
+error[E0277]: `Foo` cannot be sent between threads safely
+ --> $DIR/no_send-struct.rs:15:9
+ |
+LL | bar(x);
+ | --- ^ `Foo` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
+ |
+ = help: the trait `Send` is not implemented for `Foo`
+note: required by a bound in `bar`
+ --> $DIR/no_send-struct.rs:11:11
+ |
+LL | fn bar<T: Send>(_: T) {}
+ | ^^^^ required by this bound in `bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
|
= help: the following implementations were found:
<() as MyTrait>
-note: required by `MyTrait::foo`
- --> $DIR/no-use.rs:5:17
- |
-LL | trait MyTrait { fn foo(&self); }
- | ^^^^^^^^^^^^^^
error: aborting due to previous error
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: HasNew<Foo>`
-note: required by `HasNew::new`
- --> $DIR/static-method-generic-inference.rs:8:9
- |
-LL | fn new() -> T;
- | ^^^^^^^^^^^^^^
error: aborting due to previous error
LL | <u64 as From<T>>::from;
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `u64`
|
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
|
LL | fn check<T: Iterator, U: ?Sized>() where u64: From<T> {
LL | <u64 as From<<T as Iterator>::Item>>::from;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
|
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
|
LL | fn check<T: Iterator, U: ?Sized>() where u64: From<<T as Iterator>::Item> {
|
LL | <Misc<_> as From<T>>::from;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `Misc<_>`
- |
-note: required by `from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn from(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the size for values of type `[T]` cannot be known at compilation time
--> $DIR/suggest-where-clause.rs:28:20
| ---------- ^ the trait `TraitA` is not implemented for `{integer}`
| |
| required by a bound introduced by this call
+ |
+note: required by a bound in `TraitB::gimme_an_a`
+ --> $DIR/vtable-res-trait-param.rs:6:21
+ |
+LL | fn gimme_an_a<A:TraitA>(&self, a: A) -> isize;
+ | ^^^^^^ required by this bound in `TraitB::gimme_an_a`
error: aborting due to previous error
error: vtable entries for `<S as D>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as A>::foo_a),
- Method(<S as B>::foo_b),
- Method(<S as C>::foo_c),
- TraitVPtr(<S as C>),
- Method(<S as D>::foo_d),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as A>::foo_a),
+ Method(<S as B>::foo_b),
+ Method(<S as C>::foo_c),
+ TraitVPtr(<S as C>),
+ Method(<S as D>::foo_d),
+ ]
--> $DIR/vtable-diamond.rs:21:1
|
LL | / trait D: B + C {
| |_^
error: vtable entries for `<S as C>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as A>::foo_a),
- Method(<S as C>::foo_c),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as A>::foo_a),
+ Method(<S as C>::foo_c),
+ ]
--> $DIR/vtable-diamond.rs:15:1
|
LL | / trait C: A {
error: vtable entries for `<S as O>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as A>::foo_a),
- Method(<S as B>::foo_b),
- TraitVPtr(<S as B>),
- Method(<S as C>::foo_c),
- Method(<S as D>::foo_d),
- TraitVPtr(<S as D>),
- Method(<S as E>::foo_e),
- TraitVPtr(<S as E>),
- Method(<S as F>::foo_f),
- TraitVPtr(<S as F>),
- Method(<S as G>::foo_g),
- Method(<S as H>::foo_h),
- TraitVPtr(<S as H>),
- Method(<S as I>::foo_i),
- TraitVPtr(<S as I>),
- Method(<S as J>::foo_j),
- TraitVPtr(<S as J>),
- Method(<S as K>::foo_k),
- TraitVPtr(<S as K>),
- Method(<S as L>::foo_l),
- TraitVPtr(<S as L>),
- Method(<S as M>::foo_m),
- TraitVPtr(<S as M>),
- Method(<S as N>::foo_n),
- TraitVPtr(<S as N>),
- Method(<S as O>::foo_o),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as A>::foo_a),
+ Method(<S as B>::foo_b),
+ TraitVPtr(<S as B>),
+ Method(<S as C>::foo_c),
+ Method(<S as D>::foo_d),
+ TraitVPtr(<S as D>),
+ Method(<S as E>::foo_e),
+ TraitVPtr(<S as E>),
+ Method(<S as F>::foo_f),
+ TraitVPtr(<S as F>),
+ Method(<S as G>::foo_g),
+ Method(<S as H>::foo_h),
+ TraitVPtr(<S as H>),
+ Method(<S as I>::foo_i),
+ TraitVPtr(<S as I>),
+ Method(<S as J>::foo_j),
+ TraitVPtr(<S as J>),
+ Method(<S as K>::foo_k),
+ TraitVPtr(<S as K>),
+ Method(<S as L>::foo_l),
+ TraitVPtr(<S as L>),
+ Method(<S as M>::foo_m),
+ TraitVPtr(<S as M>),
+ Method(<S as N>::foo_n),
+ TraitVPtr(<S as N>),
+ Method(<S as O>::foo_o),
+ ]
--> $DIR/vtable-multi-level.rs:95:1
|
LL | / trait O: G + N {
| |_^
error: vtable entries for `<S as B>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as B>::foo_b),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as B>::foo_b),
+ ]
--> $DIR/vtable-multi-level.rs:19:1
|
LL | / trait B {
| |_^
error: vtable entries for `<S as D>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as D>::foo_d),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as D>::foo_d),
+ ]
--> $DIR/vtable-multi-level.rs:30:1
|
LL | / trait D {
| |_^
error: vtable entries for `<S as E>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as E>::foo_e),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as E>::foo_e),
+ ]
--> $DIR/vtable-multi-level.rs:36:1
|
LL | / trait E {
| |_^
error: vtable entries for `<S as F>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as D>::foo_d),
- Method(<S as E>::foo_e),
- TraitVPtr(<S as E>),
- Method(<S as F>::foo_f),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as D>::foo_d),
+ Method(<S as E>::foo_e),
+ TraitVPtr(<S as E>),
+ Method(<S as F>::foo_f),
+ ]
--> $DIR/vtable-multi-level.rs:42:1
|
LL | / trait F: D + E {
| |_^
error: vtable entries for `<S as H>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as H>::foo_h),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as H>::foo_h),
+ ]
--> $DIR/vtable-multi-level.rs:53:1
|
LL | / trait H {
| |_^
error: vtable entries for `<S as I>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as I>::foo_i),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as I>::foo_i),
+ ]
--> $DIR/vtable-multi-level.rs:59:1
|
LL | / trait I {
| |_^
error: vtable entries for `<S as J>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as H>::foo_h),
- Method(<S as I>::foo_i),
- TraitVPtr(<S as I>),
- Method(<S as J>::foo_j),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as H>::foo_h),
+ Method(<S as I>::foo_i),
+ TraitVPtr(<S as I>),
+ Method(<S as J>::foo_j),
+ ]
--> $DIR/vtable-multi-level.rs:65:1
|
LL | / trait J: H + I {
| |_^
error: vtable entries for `<S as K>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as K>::foo_k),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as K>::foo_k),
+ ]
--> $DIR/vtable-multi-level.rs:71:1
|
LL | / trait K {
| |_^
error: vtable entries for `<S as L>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as L>::foo_l),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as L>::foo_l),
+ ]
--> $DIR/vtable-multi-level.rs:77:1
|
LL | / trait L {
| |_^
error: vtable entries for `<S as M>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as K>::foo_k),
- Method(<S as L>::foo_l),
- TraitVPtr(<S as L>),
- Method(<S as M>::foo_m),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as K>::foo_k),
+ Method(<S as L>::foo_l),
+ TraitVPtr(<S as L>),
+ Method(<S as M>::foo_m),
+ ]
--> $DIR/vtable-multi-level.rs:83:1
|
LL | / trait M: K + L {
| |_^
error: vtable entries for `<S as N>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as H>::foo_h),
- Method(<S as I>::foo_i),
- TraitVPtr(<S as I>),
- Method(<S as J>::foo_j),
- Method(<S as K>::foo_k),
- TraitVPtr(<S as K>),
- Method(<S as L>::foo_l),
- TraitVPtr(<S as L>),
- Method(<S as M>::foo_m),
- TraitVPtr(<S as M>),
- Method(<S as N>::foo_n),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as H>::foo_h),
+ Method(<S as I>::foo_i),
+ TraitVPtr(<S as I>),
+ Method(<S as J>::foo_j),
+ Method(<S as K>::foo_k),
+ TraitVPtr(<S as K>),
+ Method(<S as L>::foo_l),
+ TraitVPtr(<S as L>),
+ Method(<S as M>::foo_m),
+ TraitVPtr(<S as M>),
+ Method(<S as N>::foo_n),
+ ]
--> $DIR/vtable-multi-level.rs:89:1
|
LL | / trait N: J + M {
error: vtable entries for `<S as C>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as A>::foo_a),
- Method(<S as B>::foo_b),
- TraitVPtr(<S as B>),
- Method(<S as C>::foo_c),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as A>::foo_a),
+ Method(<S as B>::foo_b),
+ TraitVPtr(<S as B>),
+ Method(<S as C>::foo_c),
+ ]
--> $DIR/vtable-multiple.rs:16:1
|
LL | / trait C: A + B {
| |_^
error: vtable entries for `<S as B>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as B>::foo_b),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as B>::foo_b),
+ ]
--> $DIR/vtable-multiple.rs:10:1
|
LL | / trait B {
error: vtable entries for `<std::vec::IntoIter<u8> as A>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<std::vec::IntoIter<u8> as Iterator>::next),
- Method(<std::vec::IntoIter<u8> as Iterator>::size_hint),
- Method(<std::vec::IntoIter<u8> as Iterator>::advance_by),
- Method(<std::vec::IntoIter<u8> as Iterator>::nth),
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<std::vec::IntoIter<u8> as Iterator>::next),
+ Method(<std::vec::IntoIter<u8> as Iterator>::size_hint),
+ Method(<std::vec::IntoIter<u8> as Iterator>::advance_by),
+ Method(<std::vec::IntoIter<u8> as Iterator>::nth),
+ ]
--> $DIR/vtable-non-object-safe.rs:8:1
|
LL | trait A: Iterator {}
error: vtable entries for `<S as B>`: [
- MetadataDropInPlace,
- MetadataSize,
- MetadataAlign,
- Method(<S as A>::foo_a1),
- Vacant,
- Method(<S as B>::foo_b1),
- Vacant,
-]
+ MetadataDropInPlace,
+ MetadataSize,
+ MetadataAlign,
+ Method(<S as A>::foo_a1),
+ Vacant,
+ Method(<S as B>::foo_b1),
+ Vacant,
+ ]
--> $DIR/vtable-vacant.rs:15:1
|
LL | / trait B: A {
| --------- ^^^^^ the trait `Foo` is not implemented for `i32`
| |
| required by a bound introduced by this call
- |
-note: required by `Foo::test`
- --> $DIR/trivial-bounds-leak.rs:5:5
- |
-LL | fn test(&self);
- | ^^^^^^^^^^^^^^^
error[E0277]: the trait bound `i32: Foo` is not satisfied
--> $DIR/trivial-bounds-leak.rs:26:22
= help: the following implementations were found:
<TryFromSliceError as From<Infallible>>
= note: required because of the requirements on the impl of `FromResidual<Result<Infallible, &str>>` for `Result<u32, TryFromSliceError>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Output == &str`
--> $DIR/try-block-bad-type.rs:12:9
| ^ could not wrap the final value of the block as `()` doesn't implement `Try`
|
= help: the trait `Try` is not implemented for `()`
-note: required by `from_output`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_output(output: Self::Output) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: a `try` block must return `Result` or `Option` (or another type that implements `Try`)
--> $DIR/try-block-bad-type.rs:20:26
| ^ could not wrap the final value of the block as `i32` doesn't implement `Try`
|
= help: the trait `Try` is not implemented for `i32`
-note: required by `from_output`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_output(output: Self::Output) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors
| ^^^^^ could not wrap the final value of the block as `bool` doesn't implement `Try`
|
= help: the trait `Try` is not implemented for `bool`
-note: required by `from_output`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_output(output: Self::Output) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
--- /dev/null
+// run-pass
+
+#![allow(non_camel_case_types)]
+// compile-flags: --edition 2015
+
+fn main() {
+ let try = 2;
+ struct try { try: u32 }
+ let try: try = try { try };
+ assert_eq!(try.try, 2);
+}
+++ /dev/null
-// run-pass
-
-#![allow(non_camel_case_types)]
-// compile-flags: --edition 2015
-
-fn main() {
- let try = 2;
- struct try { try: u32 }
- let try: try = try { try };
- assert_eq!(try.try, 2);
-}
<u8 as From<NonZeroU8>>
<u8 as From<bool>>
= note: required because of the requirements on the impl of `FromResidual<Result<Infallible, i32>>` for `Result<u64, u8>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
--> $DIR/bad-interconversion.rs:11:12
| |_- this function returns a `Result`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
--> $DIR/bad-interconversion.rs:17:31
| |_- this function returns a `Result`
|
= help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
--> $DIR/bad-interconversion.rs:22:22
| |_- this function returns an `Option`
|
= help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
--> $DIR/bad-interconversion.rs:27:33
| |_- this function returns an `Option`
|
= help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
--> $DIR/bad-interconversion.rs:32:39
| |_- this function returns a `ControlFlow`
|
= help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
--> $DIR/bad-interconversion.rs:37:12
| |_- this function returns a `ControlFlow`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator in a function that returns `ControlFlow<B, _>` can only be used on other `ControlFlow<B, _>`s (with the same Break type)
--> $DIR/bad-interconversion.rs:43:29
|
= help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
= note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
| |_- this function returns a `Result`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<(), ()>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
--> $DIR/option-to-result.rs:11:6
| |_- this function returns an `Option`
|
= help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-diagnostics.rs:14:10
| |_____- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-diagnostics.rs:26:14
| |_________- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option-diagnostics.rs:39:14
| |_________- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
| |_- this function returns a `Result`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u32, ()>`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-on-option.rs:13:6
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be applied to values that implement `Try`
--> $DIR/try-operator-on-main.rs:10:5
| ^^^ the `?` operator cannot be applied to type `()`
|
= help: the trait `Try` is not implemented for `()`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/try-operator-on-main.rs:10:7
| |_- this function should return `Result` or `Option` to accept `?`
|
= help: the trait `FromResidual<_>` is not implemented for `()`
-note: required by `from_residual`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn from_residual(residual: R) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `(): Try` is not satisfied
--> $DIR/try-operator-on-main.rs:14:25
| ^^^ the `?` operator cannot be applied to type `()`
|
= help: the trait `Try` is not implemented for `()`
-note: required by `branch`
- --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
- |
-LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors
+++ /dev/null
-// run-pass
-
-#![allow(stable_features)]
-// ignore-emscripten no processes
-// ignore-sgx no processes
-
-#![feature(process_try_wait)]
-
-use std::env;
-use std::process::Command;
-use std::thread;
-use std::time::Duration;
-
-fn main() {
- let args = env::args().collect::<Vec<_>>();
- if args.len() != 1 {
- match &args[1][..] {
- "sleep" => thread::sleep(Duration::new(1_000, 0)),
- _ => {}
- }
- return
- }
-
- let mut me = Command::new(env::current_exe().unwrap())
- .arg("sleep")
- .spawn()
- .unwrap();
- let maybe_status = me.try_wait().unwrap();
- assert!(maybe_status.is_none());
- let maybe_status = me.try_wait().unwrap();
- assert!(maybe_status.is_none());
-
- me.kill().unwrap();
- me.wait().unwrap();
-
- let status = me.try_wait().unwrap().unwrap();
- assert!(!status.success());
- let status = me.try_wait().unwrap().unwrap();
- assert!(!status.success());
-
- let mut me = Command::new(env::current_exe().unwrap())
- .arg("return-quickly")
- .spawn()
- .unwrap();
- loop {
- match me.try_wait() {
- Ok(Some(res)) => {
- assert!(res.success());
- break
- }
- Ok(None) => {
- thread::sleep(Duration::from_millis(1));
- }
- Err(e) => panic!("error in try_wait: {}", e),
- }
- }
-
- let status = me.try_wait().unwrap().unwrap();
- assert!(status.success());
-}
+++ /dev/null
-fn main() {
- let x = 3;
- let y: i32 = 3;
-
- fn identity_u8(n: u8) -> u8 { n }
- fn identity_u16(n: u16) -> u16 { n }
-
- identity_u8(x); // after this, `x` is assumed to have type `u8`
- identity_u16(x);
- //~^ ERROR mismatched types
- //~| expected `u16`, found `u8`
- identity_u16(y);
- //~^ ERROR mismatched types
- //~| expected `u16`, found `i32`
-
- let a = 3;
-
- fn identity_i(n: isize) -> isize { n }
-
- identity_i(a); // ok
- identity_u16(a);
- //~^ ERROR mismatched types
- //~| expected `u16`, found `isize`
-}
+++ /dev/null
-error[E0308]: mismatched types
- --> $DIR/tutorial-suffix-inference-test.rs:9:18
- |
-LL | identity_u16(x);
- | ^ expected `u16`, found `u8`
- |
-help: you can convert a `u8` to a `u16`
- |
-LL | identity_u16(x.into());
- | +++++++
-
-error[E0308]: mismatched types
- --> $DIR/tutorial-suffix-inference-test.rs:12:18
- |
-LL | identity_u16(y);
- | ^ expected `u16`, found `i32`
- |
-help: you can convert an `i32` to a `u16` and panic if the converted value doesn't fit
- |
-LL | identity_u16(y.try_into().unwrap());
- | ++++++++++++++++++++
-
-error[E0308]: mismatched types
- --> $DIR/tutorial-suffix-inference-test.rs:21:18
- |
-LL | identity_u16(a);
- | ^ expected `u16`, found `isize`
- |
-help: you can convert an `isize` to a `u16` and panic if the converted value doesn't fit
- |
-LL | identity_u16(a.try_into().unwrap());
- | ++++++++++++++++++++
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
|
help: `Alias::Unit` is a unit variant, you need to write it without the parentheses
|
-LL | Alias::Unit;
- | ~~~~~~~~~~~
+LL - Alias::Unit();
+LL + Alias::Unit;
+ |
error[E0164]: expected tuple struct or tuple variant, found unit variant `Alias::Unit`
--> $DIR/incorrect-variant-form-through-alias-caught.rs:17:9
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-#![allow(unused_variables)]
-// Type ascription doesn't lead to unsoundness
-
-#![feature(type_ascription)]
-
-use std::mem;
-
-const C1: u8 = 10: u8;
-const C2: [u8; 1: usize] = [1];
-
-struct S {
- a: u8
-}
-
-fn main() {
- assert_eq!(C1.into(): i32, 10);
- assert_eq!(C2[0], 1);
-
- let s = S { a: 10: u8 };
- let arr = &[1u8, 2, 3];
-
- let mut v = arr.iter().cloned().collect(): Vec<_>;
- v.push(4);
- assert_eq!(v, [1, 2, 3, 4]);
-
- let a = 1: u8;
- let b = a.into(): u16;
- assert_eq!(v[a.into(): usize], 2);
- assert_eq!(mem::size_of_val(&a), 1);
- assert_eq!(mem::size_of_val(&b), 2);
- assert_eq!(b, 1: u16);
-
- let mut v = Vec::new();
- v: Vec<u8> = vec![1, 2, 3]; // Place expression type ascription
- assert_eq!(v, [1u8, 2, 3]);
-}
+++ /dev/null
-// run-pass
-
-#![allow(non_upper_case_globals)]
-#![allow(dead_code)]
-#![allow(unused_assignments)]
-#![allow(unused_variables)]
-// Test a scenario where we generate a constraint like `?1 <: &?2`.
-// In such a case, it is important that we instantiate `?1` with `&?3`
-// where `?3 <: ?2`, and not with `&?2`. This is a regression test for
-// #18653. The important thing is that we build.
-
-use std::cell::RefCell;
-
-enum Wrap<A> {
- WrapSome(A),
- WrapNone
-}
-
-use Wrap::*;
-
-struct T;
-struct U;
-
-trait Get<T: ?Sized> {
- fn get(&self) -> &T;
-}
-
-impl Get<dyn MyShow + 'static> for Wrap<T> {
- fn get(&self) -> &(dyn MyShow + 'static) {
- static x: usize = 42;
- &x
- }
-}
-
-impl Get<usize> for Wrap<U> {
- fn get(&self) -> &usize {
- static x: usize = 55;
- &x
- }
-}
-
-trait MyShow { fn dummy(&self) { } }
-impl<'a> MyShow for &'a (dyn MyShow + 'a) { }
-impl MyShow for usize { }
-fn constrain<'a>(rc: RefCell<&'a (dyn MyShow + 'a)>) { }
-
-fn main() {
- let mut collection: Wrap<_> = WrapNone;
-
- {
- let __arg0 = Get::get(&collection);
- let __args_cell = RefCell::new(__arg0);
- constrain(__args_cell);
- }
- collection = WrapSome(T);
-}
--- /dev/null
+// run-pass
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+// Type ascription doesn't lead to unsoundness
+
+#![feature(type_ascription)]
+
+use std::mem;
+
+const C1: u8 = 10: u8;
+const C2: [u8; 1: usize] = [1];
+
+struct S {
+ a: u8
+}
+
+fn main() {
+ assert_eq!(C1.into(): i32, 10);
+ assert_eq!(C2[0], 1);
+
+ let s = S { a: 10: u8 };
+ let arr = &[1u8, 2, 3];
+
+ let mut v = arr.iter().cloned().collect(): Vec<_>;
+ v.push(4);
+ assert_eq!(v, [1, 2, 3, 4]);
+
+ let a = 1: u8;
+ let b = a.into(): u16;
+ assert_eq!(v[a.into(): usize], 2);
+ assert_eq!(mem::size_of_val(&a), 1);
+ assert_eq!(mem::size_of_val(&b), 2);
+ assert_eq!(b, 1: u16);
+
+ let mut v = Vec::new();
+ v: Vec<u8> = vec![1, 2, 3]; // Place expression type ascription
+ assert_eq!(v, [1u8, 2, 3]);
+}
|
LL | struct Bounds<T:Copy=String>(T);
| ^^^^ the trait `Copy` is not implemented for `String`
- |
-note: required by `Bounds`
- --> $DIR/type-check-defaults.rs:11:1
- |
-LL | struct Bounds<T:Copy=String>(T);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/type-check-defaults.rs:14:42
|
LL | struct WhereClause<T=String>(T) where T: Copy;
| ^^^^ the trait `Copy` is not implemented for `String`
- |
-note: required by `WhereClause`
- --> $DIR/type-check-defaults.rs:14:1
- |
-LL | struct WhereClause<T=String>(T) where T: Copy;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/type-check-defaults.rs:17:20
|
LL | trait TraitBound<T:Copy=String> {}
| ^^^^ the trait `Copy` is not implemented for `String`
- |
-note: required by `TraitBound`
- --> $DIR/type-check-defaults.rs:17:1
- |
-LL | trait TraitBound<T:Copy=String> {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `T: Copy` is not satisfied
--> $DIR/type-check-defaults.rs:21:25
| ^^^^^^^ no implementation for `i32 + u8`
|
= help: the trait `Add<u8>` is not implemented for `i32`
-note: required by `ProjectionPred`
- --> $DIR/type-check-defaults.rs:24:1
- |
-LL | trait ProjectionPred<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 7 previous errors
| ^^^ cannot infer type for reference `&'a T`
|
= note: cannot satisfy `&'a T: Foo`
-note: required by a bound in `Foo`
- --> $DIR/issue-40294.rs:1:1
- |
-LL | trait Foo: Sized {
- | ^^^^^^^^^^^^^^^^ required by this bound in `Foo`
error: aborting due to previous error
LL | Tr::op(u)
| ^^^^^^ the trait `Tr<U>` is not implemented for `Self`
|
-note: required by `Tr::op`
- --> $DIR/type-params-in-different-spaces-2.rs:5:5
- |
-LL | fn op(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^
help: consider further restricting `Self`
|
LL | fn test<U>(u: U) -> Self where Self: Tr<U> {
LL | Tr::op(u)
| ^^^^^^ the trait `Tr<U>` is not implemented for `Self`
|
-note: required by `Tr::op`
- --> $DIR/type-params-in-different-spaces-2.rs:5:5
- |
-LL | fn op(_: T) -> Self;
- | ^^^^^^^^^^^^^^^^^^^^
help: consider further restricting `Self`
|
LL | fn test<U>(u: U) -> Self where Self: Tr<U> {
--> $DIR/issue-46112.rs:9:21
|
LL | fn main() { test(Ok(())); }
- | ^^
- | |
- | expected enum `Option`, found `()`
- | help: try using a variant of the expected enum: `Some(())`
+ | ^^ expected enum `Option`, found `()`
|
= note: expected enum `Option<()>`
found unit type `()`
+help: try wrapping the expression in `Some`
+ |
+LL | fn main() { test(Ok(Some(()))); }
+ | +++++ +
error: aborting due to previous error
--- /dev/null
+// Related issues: #20401, #20506, #20614, #20752, #20829, #20846, #20885, #20886
+
+fn main() {
+ "".homura[""]; //~ no field `homura` on type `&'static str`
+}
--- /dev/null
+error[E0609]: no field `homura` on type `&'static str`
+ --> $DIR/no-type-for-node-ice.rs:4:8
+ |
+LL | "".homura[""];
+ | ^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0609`.
--- /dev/null
+// run-pass
+
+#![allow(dead_code)]
+// Regression test for #37154: the problem here was that the cache
+// results in a false error because it was caching placeholder results
+// even after those placeholder regions had been popped.
+
+trait Foo {
+ fn method(&self) {}
+}
+
+struct Wrapper<T>(T);
+
+impl<T> Foo for Wrapper<T> where for<'a> &'a T: IntoIterator<Item=&'a ()> {}
+
+fn f(x: Wrapper<Vec<()>>) {
+ x.method(); // This works.
+ x.method(); // error: no method named `method`
+}
+
+fn main() { }
--- /dev/null
+// run-pass
+// pretty-expanded FIXME #23616
+
+trait Foo<T> {
+ fn get(&self) -> T;
+}
+
+impl Foo<i32> for i32 {
+ fn get(&self) -> i32 { *self }
+}
+
+fn main() {
+ let x: i32 = 1;
+ Foo::<i32>::get(&x);
+}
--- /dev/null
+// run-pass
+// Tests that the tail expr in null() has its type
+// unified with the type *T, and so the type variable
+// in that type gets resolved.
+
+// pretty-expanded FIXME #23616
+
+use std::mem;
+
+fn null<T>() -> *const T {
+ unsafe {
+ mem::transmute(0_usize)
+ }
+}
+
+pub fn main() { null::<isize>(); }
+++ /dev/null
-// run-pass
-// pretty-expanded FIXME #23616
-
-trait Foo<T> {
- fn get(&self) -> T;
-}
-
-impl Foo<i32> for i32 {
- fn get(&self) -> i32 { *self }
-}
-
-fn main() {
- let x: i32 = 1;
- Foo::<i32>::get(&x);
-}
| ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32`
|
= help: the trait `Add<u32>` is not implemented for `i32`
-note: required by `add`
- --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
- |
-LL | fn add(self, rhs: Rhs) -> Self::Output;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/ufcs-qpath-self-mismatch.rs:6:28
|
= help: the following implementations were found:
<[(); 1] as Foo>
-note: required by `Foo::foo`
- --> $DIR/unevaluated_fixed_size_array_len.rs:4:5
- |
-LL | fn foo();
- | ^^^^^^^^^
error: aborting due to previous error
+++ /dev/null
-// run-pass
-// Tests that the tail expr in null() has its type
-// unified with the type *T, and so the type variable
-// in that type gets resolved.
-
-// pretty-expanded FIXME #23616
-
-use std::mem;
-
-fn null<T>() -> *const T {
- unsafe {
- mem::transmute(0_usize)
- }
-}
-
-pub fn main() { null::<isize>(); }
LL | let u = U { a: Rc::new(0u32) };
| ^ the trait `Copy` is not implemented for `Rc<u32>`
|
-note: required by `U`
- --> $DIR/union-generic.rs:6:1
+note: required by a bound in `U`
+ --> $DIR/union-generic.rs:6:12
|
LL | union U<T: Copy> {
- | ^^^^^^^^^^^^^^^^
+ | ^^^^ required by this bound in `U`
error[E0277]: the trait bound `Rc<u32>: Copy` is not satisfied
--> $DIR/union-generic.rs:13:13
LL | let u = U::<Rc<u32>> { a: Default::default() };
| ^^^^^^^^^^^^ the trait `Copy` is not implemented for `Rc<u32>`
|
-note: required by `U`
- --> $DIR/union-generic.rs:6:1
+note: required by a bound in `U`
+ --> $DIR/union-generic.rs:6:12
|
LL | union U<T: Copy> {
- | ^^^^^^^^^^^^^^^^
+ | ^^^^ required by this bound in `U`
error: aborting due to 2 previous errors
LL | let u = U { a: Rc::new(0u32) };
| ^ the trait `Copy` is not implemented for `Rc<u32>`
|
-note: required by `U`
- --> $DIR/union-generic.rs:6:1
+note: required by a bound in `U`
+ --> $DIR/union-generic.rs:6:12
|
LL | union U<T: Copy> {
- | ^^^^^^^^^^^^^^^^
+ | ^^^^ required by this bound in `U`
error[E0277]: the trait bound `Rc<u32>: Copy` is not satisfied
--> $DIR/union-generic.rs:13:13
LL | let u = U::<Rc<u32>> { a: Default::default() };
| ^^^^^^^^^^^^ the trait `Copy` is not implemented for `Rc<u32>`
|
-note: required by `U`
- --> $DIR/union-generic.rs:6:1
+note: required by a bound in `U`
+ --> $DIR/union-generic.rs:6:12
|
LL | union U<T: Copy> {
- | ^^^^^^^^^^^^^^^^
+ | ^^^^ required by this bound in `U`
error: aborting due to 2 previous errors
|
LL | let x = x.cast::<[i32]>();
| ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo`
+ |
+note: required by a bound in `Cast::cast`
+ --> $DIR/issue-71659.rs:19:15
+ |
+LL | fn cast<T: ?Sized>(&self) -> &T
+ | ---- required by a bound in this
+LL | where
+LL | Self: CastTo<T>,
+ | ^^^^^^^^^ required by this bound in `Cast::cast`
error: aborting due to previous error
--- /dev/null
+struct S1<T>(T) where (T): ?Sized;
+//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
+
+struct S2<T>(T) where u8: ?Sized;
+//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
+
+struct S3<T>(T) where &'static T: ?Sized;
+//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
+
+trait Trait<'a> {}
+
+struct S4<T>(T) where for<'a> T: ?Trait<'a>;
+//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
+//~| WARN default bound relaxed for a type parameter
+
+struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
+//~^ ERROR type parameter has more than one relaxed default bound
+//~| WARN default bound relaxed for a type parameter
+
+impl<T> S1<T> {
+ fn f() where T: ?Sized {}
+ //~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared
+}
+
+fn main() {
+ let u = vec![1, 2, 3];
+ let _s: S5<[u8]> = S5(&u[..]); // OK
+}
--- /dev/null
+error: `?Trait` bounds are only permitted at the point where a type parameter is declared
+ --> $DIR/maybe-bounds-where.rs:1:28
+ |
+LL | struct S1<T>(T) where (T): ?Sized;
+ | ^^^^^^
+
+error: `?Trait` bounds are only permitted at the point where a type parameter is declared
+ --> $DIR/maybe-bounds-where.rs:4:27
+ |
+LL | struct S2<T>(T) where u8: ?Sized;
+ | ^^^^^^
+
+error: `?Trait` bounds are only permitted at the point where a type parameter is declared
+ --> $DIR/maybe-bounds-where.rs:7:35
+ |
+LL | struct S3<T>(T) where &'static T: ?Sized;
+ | ^^^^^^
+
+error: `?Trait` bounds are only permitted at the point where a type parameter is declared
+ --> $DIR/maybe-bounds-where.rs:12:34
+ |
+LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>;
+ | ^^^^^^^^^^
+
+error: `?Trait` bounds are only permitted at the point where a type parameter is declared
+ --> $DIR/maybe-bounds-where.rs:21:21
+ |
+LL | fn f() where T: ?Sized {}
+ | ^^^^^^
+
+warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
+ --> $DIR/maybe-bounds-where.rs:12:11
+ |
+LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>;
+ | ^
+
+error[E0203]: type parameter has more than one relaxed default bound, only one is supported
+ --> $DIR/maybe-bounds-where.rs:16:11
+ |
+LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
+ | ^
+
+warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported
+ --> $DIR/maybe-bounds-where.rs:16:11
+ |
+LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized;
+ | ^
+
+error: aborting due to 6 previous errors; 2 warnings emitted
+
+For more information about this error, try `rustc --explain E0203`.
+++ /dev/null
-// run-pass
-
-#![allow(stable_features)]
-#![feature(volatile)]
-use std::ptr::{read_volatile, write_volatile};
-
-fn main() {
- let mut x: &'static str = "test";
- unsafe {
- let a = read_volatile(&x);
- assert_eq!(a, "test");
- write_volatile(&mut x, "foo");
- assert_eq!(x, "foo");
- }
-}
+++ /dev/null
-#[link(name = "...", wasm_import_module)] //~ ERROR: must be of the form
-extern "C" {}
-
-#[link(name = "...", wasm_import_module(x))] //~ ERROR: must be of the form
-extern "C" {}
-
-#[link(name = "...", wasm_import_module())] //~ ERROR: must be of the form
-extern "C" {}
-
-fn main() {}
+++ /dev/null
-error: must be of the form `#[link(wasm_import_module = "...")]`
- --> $DIR/wasm-import-module.rs:1:22
- |
-LL | #[link(name = "...", wasm_import_module)]
- | ^^^^^^^^^^^^^^^^^^
-
-error: must be of the form `#[link(wasm_import_module = "...")]`
- --> $DIR/wasm-import-module.rs:4:22
- |
-LL | #[link(name = "...", wasm_import_module(x))]
- | ^^^^^^^^^^^^^^^^^^^^^
-
-error: must be of the form `#[link(wasm_import_module = "...")]`
- --> $DIR/wasm-import-module.rs:7:22
- |
-LL | #[link(name = "...", wasm_import_module())]
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 3 previous errors
-
--- /dev/null
+#[link(name = "...", wasm_import_module)] //~ ERROR: must be of the form
+extern "C" {}
+
+#[link(name = "...", wasm_import_module(x))] //~ ERROR: must be of the form
+extern "C" {}
+
+#[link(name = "...", wasm_import_module())] //~ ERROR: must be of the form
+extern "C" {}
+
+fn main() {}
--- /dev/null
+error: must be of the form `#[link(wasm_import_module = "...")]`
+ --> $DIR/wasm-import-module.rs:1:22
+ |
+LL | #[link(name = "...", wasm_import_module)]
+ | ^^^^^^^^^^^^^^^^^^
+
+error: must be of the form `#[link(wasm_import_module = "...")]`
+ --> $DIR/wasm-import-module.rs:4:22
+ |
+LL | #[link(name = "...", wasm_import_module(x))]
+ | ^^^^^^^^^^^^^^^^^^^^^
+
+error: must be of the form `#[link(wasm_import_module = "...")]`
+ --> $DIR/wasm-import-module.rs:7:22
+ |
+LL | #[link(name = "...", wasm_import_module())]
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-#![allow(unused_variables)]
-// Test that the `wf` checker properly handles bound regions in object
-// types. Compiling this code used to trigger an ICE.
-
-// pretty-expanded FIXME #23616
-
-pub struct Context<'tcx> {
- vec: &'tcx Vec<isize>
-}
-
-pub type Cmd<'a> = &'a isize;
-
-pub type DecodeInlinedItem<'a> =
- Box<dyn for<'tcx> FnMut(Cmd, &Context<'tcx>) -> Result<&'tcx isize, ()> + 'a>;
-
-fn foo(d: DecodeInlinedItem) {
-}
-
-fn main() { }
|
LL | pub fn lint_me() -> <() as Foo>::Assoc;
| ^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()`
- |
-note: required by a bound in `Foo`
- --> $DIR/wf-foreign-fn-decl-ret.rs:6:1
- |
-LL | pub trait Foo {
- | ^^^^^^^^^^^^^ required by this bound in `Foo`
error[E0277]: the trait bound `u32: Unsatisfied` is not satisfied
--> $DIR/wf-foreign-fn-decl-ret.rs:14:32
|
LL | 1.method::<X>();
| ^^^^^^ the trait `Foo<X>` is not implemented for `X`
+ |
+note: required by a bound in `Bar::method`
+ --> $DIR/where-clause-method-substituion.rs:6:34
+ |
+LL | fn method<B>(&self) where A: Foo<B>;
+ | ^^^^^^ required by this bound in `Bar::method`
error: aborting due to previous error
| ------ ^^ the trait `Eq` is not implemented for `Bar`
| |
| required by a bound introduced by this call
+ |
+note: required by a bound in `Foo::<T>::equals`
+ --> $DIR/where-clauses-method-unsatisfied.rs:11:52
+ |
+LL | fn equals(&self, u: &Foo<T>) -> bool where T : Eq {
+ | ^^ required by this bound in `Foo::<T>::equals`
error: aborting due to previous error
-Subproject commit ad50d0d266213e0cc4f6e526a39d96faae9a3842
+Subproject commit e1fb17631eb1b3665cdbe45b1c186111577ef512
-use super::{
- get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP,
-};
+use super::{make_iterator_snippet, IncrementVisitor, InitializeVisitor, EXPLICIT_COUNTER_LOOP};
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::{get_enclosing_block, is_integer_const};
then {
let mut applicability = Applicability::MachineApplicable;
- let for_span = get_span_of_entire_for_loop(expr);
-
span_lint_and_sugg(
cx,
EXPLICIT_COUNTER_LOOP,
- for_span.with_hi(arg.span.hi()),
+ expr.span.with_hi(arg.span.hi()),
&format!("the variable `{}` is used as a loop counter", name),
"consider using",
format!(
-use super::{get_span_of_entire_for_loop, IncrementVisitor, InitializeVisitor, MANUAL_MEMCPY};
+use super::{IncrementVisitor, InitializeVisitor, MANUAL_MEMCPY};
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::source::snippet;
use clippy_utils::sugg::Sugg;
span_lint_and_sugg(
cx,
MANUAL_MEMCPY,
- get_span_of_entire_for_loop(expr),
+ expr.span,
"it looks like you're manually copying between slices",
"try replacing the loop by",
big_sugg,
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
-use utils::{get_span_of_entire_for_loop, make_iterator_snippet, IncrementVisitor, InitializeVisitor};
+use utils::{make_iterator_snippet, IncrementVisitor, InitializeVisitor};
declare_clippy_lint! {
/// ### What it does
impl<'tcx> LateLintPass<'tcx> for Loops {
#[allow(clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
- if let Some(higher::ForLoop { pat, arg, body, span }) = higher::ForLoop::hir(expr) {
+ let for_loop = higher::ForLoop::hir(expr);
+ if let Some(higher::ForLoop {
+ pat,
+ arg,
+ body,
+ loop_id,
+ span,
+ }) = for_loop
+ {
// we don't want to check expanded macros
// this check is not at the top of the function
// since higher::for_loop expressions are marked as expansions
return;
}
check_for_loop(cx, pat, arg, body, expr, span);
+ if let ExprKind::Block(block, _) = body.kind {
+ never_loop::check(cx, block, loop_id, span, for_loop.as_ref());
+ }
}
// we don't want to check expanded macros
}
// check for never_loop
- never_loop::check(cx, expr);
+ if let ExprKind::Loop(block, ..) = expr.kind {
+ never_loop::check(cx, block, expr.hir_id, expr.span, None);
+ }
// check for `loop { if let {} else break }` that could be `while let`
// (also matches an explicit "match" instead of "if let")
use clippy_utils::higher::ForLoop;
use clippy_utils::source::snippet;
use rustc_errors::Applicability;
-use rustc_hir::{Block, Expr, ExprKind, HirId, InlineAsmOperand, LoopSource, Node, Pat, Stmt, StmtKind};
+use rustc_hir::{Block, Expr, ExprKind, HirId, InlineAsmOperand, Pat, Stmt, StmtKind};
use rustc_lint::LateContext;
+use rustc_span::Span;
use std::iter::{once, Iterator};
-pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
- if let ExprKind::Loop(block, _, source, _) = expr.kind {
- match never_loop_block(block, expr.hir_id) {
- NeverLoopResult::AlwaysBreak => {
- span_lint_and_then(cx, NEVER_LOOP, expr.span, "this loop never actually loops", |diag| {
- if_chain! {
- if source == LoopSource::ForLoop;
- if let Some((_, Node::Expr(parent_match))) = cx.tcx.hir().parent_iter(expr.hir_id).nth(1);
- if let Some(ForLoop { arg: iterator, pat, span: for_span, .. }) = ForLoop::hir(parent_match);
- then {
- // Suggests using an `if let` instead. This is `Unspecified` because the
- // loop may (probably) contain `break` statements which would be invalid
- // in an `if let`.
- diag.span_suggestion_verbose(
- for_span.with_hi(iterator.span.hi()),
- "if you need the first element of the iterator, try writing",
- for_to_if_let_sugg(cx, iterator, pat),
- Applicability::Unspecified,
- );
- }
- };
- });
- },
- NeverLoopResult::MayContinueMainLoop | NeverLoopResult::Otherwise => (),
- }
+pub(super) fn check(
+ cx: &LateContext<'tcx>,
+ block: &'tcx Block<'_>,
+ loop_id: HirId,
+ span: Span,
+ for_loop: Option<&ForLoop<'_>>,
+) {
+ match never_loop_block(block, loop_id) {
+ NeverLoopResult::AlwaysBreak => {
+ span_lint_and_then(cx, NEVER_LOOP, span, "this loop never actually loops", |diag| {
+ if let Some(ForLoop {
+ arg: iterator,
+ pat,
+ span: for_span,
+ ..
+ }) = for_loop
+ {
+ // Suggests using an `if let` instead. This is `Unspecified` because the
+ // loop may (probably) contain `break` statements which would be invalid
+ // in an `if let`.
+ diag.span_suggestion_verbose(
+ for_span.with_hi(iterator.span.hi()),
+ "if you need the first element of the iterator, try writing",
+ for_to_if_let_sugg(cx, iterator, pat),
+ Applicability::Unspecified,
+ );
+ }
+ });
+ },
+ NeverLoopResult::MayContinueMainLoop | NeverLoopResult::Otherwise => (),
}
}
-use super::{get_span_of_entire_for_loop, SINGLE_ELEMENT_LOOP};
+use super::SINGLE_ELEMENT_LOOP;
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::single_segment_path;
use clippy_utils::source::{indent_of, snippet};
if !block.stmts.is_empty();
then {
- let for_span = get_span_of_entire_for_loop(expr);
let mut block_str = snippet(cx, block.span, "..").into_owned();
block_str.remove(0);
block_str.pop();
span_lint_and_sugg(
cx,
SINGLE_ELEMENT_LOOP,
- for_span,
+ expr.span,
"for loop over a single element",
"try",
format!("{{\n{}let {} = &{};{}}}", " ".repeat(indent_of(cx, block.stmts[0].span).unwrap_or(0)), target.name, list_item_name, block_str),
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Stmt, StmtKind};
use rustc_lint::LateContext;
use rustc_middle::hir::map::Map;
-use rustc_span::source_map::Span;
use rustc_span::symbol::{sym, Symbol};
use std::iter::Iterator;
}
}
-// this function assumes the given expression is a `for` loop.
-pub(super) fn get_span_of_entire_for_loop(expr: &Expr<'_>) -> Span {
- // for some reason this is the only way to get the `Span`
- // of the entire `for` loop
- if let ExprKind::Match(_, arms, _) = &expr.kind {
- arms[0].body.span
- } else {
- unreachable!()
- }
-}
-
/// If `arg` was the argument to a `for` loop, return the "cleanest" way of writing the
/// actual `Iterator` that the loop uses.
pub(super) fn make_iterator_snippet(cx: &LateContext<'_>, arg: &Expr<'_>, applic_ref: &mut Applicability) -> String {
use clippy_utils::consts::{constant, Constant};
use clippy_utils::sugg::Sugg;
use clippy_utils::{
- expr_path_res, get_item_name, get_parent_expr, higher, in_constant, is_diag_trait_item, is_integer_const,
- iter_input_pats, last_path_segment, match_any_def_paths, paths, unsext, SpanlessEq,
+ expr_path_res, get_item_name, get_parent_expr, in_constant, is_diag_trait_item, is_integer_const, iter_input_pats,
+ last_path_segment, match_any_def_paths, paths, unsext, SpanlessEq,
};
declare_clippy_lint! {
if let StmtKind::Local(local) = stmt.kind;
if let PatKind::Binding(an, .., name, None) = local.pat.kind;
if let Some(init) = local.init;
- if !higher::is_from_for_desugar(local);
if an == BindingAnnotation::Ref || an == BindingAnnotation::RefMut;
then {
// use the macro callsite when the init span (but not the whole local span)
use clippy_utils::diagnostics::span_lint_and_help;
-use clippy_utils::last_path_segment;
use rustc_hir::{
- intravisit, Body, Expr, ExprKind, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatField, PatKind,
- QPath, Stmt, StmtKind,
+ intravisit, Body, Expr, ExprKind, FnDecl, HirId, LocalSource, Mutability, Pat, PatKind, Stmt, StmtKind,
};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
-use rustc_middle::ty::subst::SubstsRef;
-use rustc_middle::ty::{AdtDef, FieldDef, Ty, TyKind, VariantDef};
+use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
-use std::iter;
declare_clippy_lint! {
/// ### What it does
impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch {
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
if let StmtKind::Local(local) = stmt.kind {
- if let Some(init) = &local.init {
- if let Some(init_ty) = cx.typeck_results().node_type_opt(init.hir_id) {
- let pat = &local.pat;
- if in_external_macro(cx.sess(), pat.span) {
- return;
- }
- let deref_possible = match local.source {
- LocalSource::Normal => DerefPossible::Possible,
- _ => DerefPossible::Impossible,
- };
- apply_lint(cx, pat, init_ty, deref_possible);
- }
+ if in_external_macro(cx.sess(), local.pat.span) {
+ return;
}
+ let deref_possible = match local.source {
+ LocalSource::Normal => DerefPossible::Possible,
+ _ => DerefPossible::Impossible,
+ };
+ apply_lint(cx, local.pat, deref_possible);
}
}
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
- if let ExprKind::Match(scrutinee, arms, MatchSource::Normal) = expr.kind {
- if let Some(expr_ty) = cx.typeck_results().node_type_opt(scrutinee.hir_id) {
- 'pattern_checks: for arm in arms {
- let pat = &arm.pat;
- if in_external_macro(cx.sess(), pat.span) {
- continue 'pattern_checks;
- }
- if apply_lint(cx, pat, expr_ty, DerefPossible::Possible) {
- break 'pattern_checks;
- }
+ if let ExprKind::Match(_, arms, _) = expr.kind {
+ for arm in arms {
+ let pat = &arm.pat;
+ if apply_lint(cx, pat, DerefPossible::Possible) {
+ break;
}
}
}
- if let ExprKind::Let(let_pat, let_expr, _) = expr.kind {
- if let Some(expr_ty) = cx.typeck_results().node_type_opt(let_expr.hir_id) {
- if in_external_macro(cx.sess(), let_pat.span) {
- return;
- }
- apply_lint(cx, let_pat, expr_ty, DerefPossible::Possible);
- }
+ if let ExprKind::Let(let_pat, ..) = expr.kind {
+ apply_lint(cx, let_pat, DerefPossible::Possible);
}
}
_: &'tcx FnDecl<'_>,
body: &'tcx Body<'_>,
_: Span,
- hir_id: HirId,
+ _: HirId,
) {
- if let Some(fn_sig) = cx.typeck_results().liberated_fn_sigs().get(hir_id) {
- for (param, ty) in iter::zip(body.params, fn_sig.inputs()) {
- apply_lint(cx, param.pat, ty, DerefPossible::Impossible);
- }
+ for param in body.params {
+ apply_lint(cx, param.pat, DerefPossible::Impossible);
}
}
}
Impossible,
}
-fn apply_lint<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'_>, expr_ty: Ty<'tcx>, deref_possible: DerefPossible) -> bool {
- let maybe_mismatch = find_first_mismatch(cx, pat, expr_ty, Level::Top);
+fn apply_lint<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'_>, deref_possible: DerefPossible) -> bool {
+ let maybe_mismatch = find_first_mismatch(cx, pat);
if let Some((span, mutability, level)) = maybe_mismatch {
span_lint_and_help(
cx,
}
#[allow(rustc::usage_of_ty_tykind)]
-fn find_first_mismatch<'tcx>(
- cx: &LateContext<'tcx>,
- pat: &Pat<'_>,
- ty: Ty<'tcx>,
- level: Level,
-) -> Option<(Span, Mutability, Level)> {
- if let PatKind::Ref(sub_pat, _) = pat.kind {
- if let TyKind::Ref(_, sub_ty, _) = ty.kind() {
- return find_first_mismatch(cx, sub_pat, sub_ty, Level::Lower);
- }
- }
-
- if let TyKind::Ref(_, _, mutability) = *ty.kind() {
- if is_non_ref_pattern(&pat.kind) {
- return Some((pat.span, mutability, level));
- }
- }
-
- if let PatKind::Struct(ref qpath, field_pats, _) = pat.kind {
- if let TyKind::Adt(adt_def, substs_ref) = ty.kind() {
- if let Some(variant) = get_variant(adt_def, qpath) {
- let field_defs = &variant.fields;
- return find_first_mismatch_in_struct(cx, field_pats, field_defs, substs_ref);
- }
+fn find_first_mismatch<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'_>) -> Option<(Span, Mutability, Level)> {
+ let mut result = None;
+ pat.walk(|p| {
+ if result.is_some() {
+ return false;
}
- }
-
- if let PatKind::TupleStruct(ref qpath, pats, _) = pat.kind {
- if let TyKind::Adt(adt_def, substs_ref) = ty.kind() {
- if let Some(variant) = get_variant(adt_def, qpath) {
- let field_defs = &variant.fields;
- let ty_iter = field_defs.iter().map(|field_def| field_def.ty(cx.tcx, substs_ref));
- return find_first_mismatch_in_tuple(cx, pats, ty_iter);
- }
- }
- }
-
- if let PatKind::Tuple(pats, _) = pat.kind {
- if let TyKind::Tuple(..) = ty.kind() {
- return find_first_mismatch_in_tuple(cx, pats, ty.tuple_fields());
+ if in_external_macro(cx.sess(), p.span) {
+ return true;
}
- }
-
- if let PatKind::Or(sub_pats) = pat.kind {
- for pat in sub_pats {
- let maybe_mismatch = find_first_mismatch(cx, pat, ty, level);
- if let Some(mismatch) = maybe_mismatch {
- return Some(mismatch);
- }
- }
- }
-
- None
-}
-
-fn get_variant<'a>(adt_def: &'a AdtDef, qpath: &QPath<'_>) -> Option<&'a VariantDef> {
- if adt_def.is_struct() {
- if let Some(variant) = adt_def.variants.iter().next() {
- return Some(variant);
- }
- }
-
- if adt_def.is_enum() {
- let pat_ident = last_path_segment(qpath).ident;
- for variant in &adt_def.variants {
- if variant.ident == pat_ident {
- return Some(variant);
- }
- }
- }
-
- None
-}
-
-fn find_first_mismatch_in_tuple<'tcx, I>(
- cx: &LateContext<'tcx>,
- pats: &[Pat<'_>],
- ty_iter_src: I,
-) -> Option<(Span, Mutability, Level)>
-where
- I: IntoIterator<Item = Ty<'tcx>>,
-{
- let mut field_tys = ty_iter_src.into_iter();
- 'fields: for pat in pats {
- let field_ty = if let Some(ty) = field_tys.next() {
- ty
- } else {
- break 'fields;
+ let adjust_pat = match p.kind {
+ PatKind::Or([p, ..]) => p,
+ _ => p,
};
-
- let maybe_mismatch = find_first_mismatch(cx, pat, field_ty, Level::Lower);
- if let Some(mismatch) = maybe_mismatch {
- return Some(mismatch);
- }
- }
-
- None
-}
-
-fn find_first_mismatch_in_struct<'tcx>(
- cx: &LateContext<'tcx>,
- field_pats: &[PatField<'_>],
- field_defs: &[FieldDef],
- substs_ref: SubstsRef<'tcx>,
-) -> Option<(Span, Mutability, Level)> {
- for field_pat in field_pats {
- 'definitions: for field_def in field_defs {
- if field_pat.ident == field_def.ident {
- let field_ty = field_def.ty(cx.tcx, substs_ref);
- let pat = &field_pat.pat;
- let maybe_mismatch = find_first_mismatch(cx, pat, field_ty, Level::Lower);
- if let Some(mismatch) = maybe_mismatch {
- return Some(mismatch);
+ if let Some(adjustments) = cx.typeck_results().pat_adjustments().get(adjust_pat.hir_id) {
+ if let [first, ..] = **adjustments {
+ if let ty::Ref(.., mutability) = *first.kind() {
+ let level = if p.hir_id == pat.hir_id {
+ Level::Top
+ } else {
+ Level::Lower
+ };
+ result = Some((p.span, mutability, level));
}
- break 'definitions;
}
}
- }
-
- None
-}
-
-fn is_non_ref_pattern(pat_kind: &PatKind<'_>) -> bool {
- match pat_kind {
- PatKind::Struct(..) | PatKind::Tuple(..) | PatKind::TupleStruct(..) | PatKind::Path(..) => true,
- PatKind::Or(sub_pats) => sub_pats.iter().any(|pat| is_non_ref_pattern(&pat.kind)),
- _ => false,
- }
+ result.is_none()
+ });
+ result
}
use clippy_utils::{match_def_path, paths};
use if_chain::if_chain;
use rustc_errors::Applicability;
-use rustc_hir::{
- self as hir, GenericArg, GenericBounds, GenericParamKind, HirId, Lifetime, MutTy, Mutability, Node, QPath,
- SyntheticTyParamKind, TyKind,
-};
+use rustc_hir::{self as hir, GenericArg, GenericBounds, GenericParamKind};
+use rustc_hir::{HirId, Lifetime, MutTy, Mutability, Node, QPath, TyKind};
use rustc_lint::LateContext;
use super::BORROWED_BOX;
if let Some(did) = cx.qpath_res(qpath, id).opt_def_id();
if let Some(Node::GenericParam(generic_param)) = cx.tcx.hir().get_if_local(did);
if let GenericParamKind::Type { synthetic, .. } = generic_param.kind;
- if synthetic == Some(SyntheticTyParamKind::ImplTrait);
+ if synthetic;
then {
Some(generic_param.bounds)
} else {
use clippy_utils::diagnostics::span_lint_and_then;
-use clippy_utils::higher;
use clippy_utils::source::snippet_with_macro_callsite;
use rustc_errors::Applicability;
use rustc_hir::{Stmt, StmtKind};
if in_external_macro(cx.sess(), stmt.span) || local.pat.span.from_expansion() {
return;
}
- if higher::is_from_for_desugar(local) {
- return;
- }
span_lint_and_then(
cx,
LET_UNIT_VALUE,
pub arg: &'tcx hir::Expr<'tcx>,
/// `for` loop body
pub body: &'tcx hir::Expr<'tcx>,
+ /// Compare this against `hir::Destination.target`
+ pub loop_id: HirId,
/// entire `for` loop span
pub span: Span,
}
impl<'tcx> ForLoop<'tcx> {
- #[inline]
/// Parses a desugared `for` loop
pub fn hir(expr: &Expr<'tcx>) -> Option<Self> {
if_chain! {
- if let hir::ExprKind::Match(iterexpr, arms, hir::MatchSource::ForLoopDesugar) = expr.kind;
- if let Some(first_arm) = arms.get(0);
- if let hir::ExprKind::Call(_, iterargs) = iterexpr.kind;
- if let Some(first_arg) = iterargs.get(0);
- if iterargs.len() == 1 && arms.len() == 1 && first_arm.guard.is_none();
- if let hir::ExprKind::Loop(block, ..) = first_arm.body.kind;
- if block.expr.is_none();
- if let [ _, _, ref let_stmt, ref body ] = *block.stmts;
- if let hir::StmtKind::Local(local) = let_stmt.kind;
- if let hir::StmtKind::Expr(body_expr) = body.kind;
+ if let hir::ExprKind::DropTemps(e) = expr.kind;
+ if let hir::ExprKind::Match(iterexpr, [arm], hir::MatchSource::ForLoopDesugar) = e.kind;
+ if let hir::ExprKind::Call(_, [arg]) = iterexpr.kind;
+ if let hir::ExprKind::Loop(block, ..) = arm.body.kind;
+ if let [stmt] = &*block.stmts;
+ if let hir::StmtKind::Expr(e) = stmt.kind;
+ if let hir::ExprKind::Match(_, [_, some_arm], _) = e.kind;
+ if let hir::PatKind::Struct(_, [field], _) = some_arm.pat.kind;
then {
return Some(Self {
- pat: &*local.pat,
- arg: first_arg,
- body: body_expr,
- span: first_arm.span
+ pat: field.pat,
+ arg,
+ body: some_arm.body,
+ loop_id: arm.body.hir_id,
+ span: expr.span.ctxt().outer_expn_data().call_site,
});
}
}
}
}
-/// Checks if a `let` statement is from a `for` loop desugaring.
-pub fn is_from_for_desugar(local: &hir::Local<'_>) -> bool {
- // This will detect plain for-loops without an actual variable binding:
- //
- // ```
- // for x in some_vec {
- // // do stuff
- // }
- // ```
- if_chain! {
- if let Some(expr) = local.init;
- if let hir::ExprKind::Match(_, _, hir::MatchSource::ForLoopDesugar) = expr.kind;
- then {
- return true;
- }
- }
-
- // This detects a variable binding in for loop to avoid `let_unit_value`
- // lint (see issue #1964).
- //
- // ```
- // for _ in vec![()] {
- // // anything
- // }
- // ```
- if let hir::LocalSource::ForLoopDesugar = local.source {
- return true;
- }
-
- false
-}
-
/// A parsed `panic!` expansion
pub struct PanicExpn<'tcx> {
/// Span of `panic!(..)`
// unimplemented: field checks
if arms.len() == 1;
if let ExprKind::Loop(ref body, ref label, LoopSource::ForLoop) = arms[0].body.kind;
- if body.stmts.len() == 4;
- if let StmtKind::Local(ref local) = body.stmts[0].kind;
- if let PatKind::Binding(BindingAnnotation::Mutable, _, name, None) = local.pat.kind;
- if name.as_str() == "__next";
- if let StmtKind::Expr(ref e, _) = body.stmts[1].kind
+ if body.stmts.len() == 1;
+ if let StmtKind::Expr(ref e, _) = body.stmts[0].kind
if let ExprKind::Match(ref expr2, ref arms1, MatchSource::ForLoopDesugar) = e.kind;
if let ExprKind::Call(ref func1, ref args1) = expr2.kind;
if let ExprKind::Path(ref path2) = func1.kind;
if let ExprKind::Path(ref path3) = inner.kind;
if match_qpath(path3, &["iter"]);
if arms1.len() == 2;
- if let ExprKind::Assign(ref target, ref value, ref _span) = arms1[0].body.kind;
- if let ExprKind::Path(ref path4) = target.kind;
- if match_qpath(path4, &["__next"]);
- if let ExprKind::Path(ref path5) = value.kind;
- if match_qpath(path5, &["val"]);
- if let PatKind::Struct(ref path6, ref fields1, false) = arms1[0].pat.kind;
- if matches!(path6, QPath::LangItem(LangItem::OptionSome, _));
- if fields1.len() == 1;
- // unimplemented: field checks
- if let ExprKind::Break(ref destination, None) = arms1[1].body.kind;
- if let PatKind::Struct(ref path7, ref fields2, false) = arms1[1].pat.kind;
- if matches!(path7, QPath::LangItem(LangItem::OptionNone, _));
- if fields2.len() == 0;
+ if let ExprKind::Break(ref destination, None) = arms1[0].body.kind;
+ if let PatKind::Struct(ref path4, ref fields1, false) = arms1[0].pat.kind;
+ if matches!(path4, QPath::LangItem(LangItem::OptionNone, _));
+ if fields1.len() == 0;
// unimplemented: field checks
- if let StmtKind::Local(ref local1) = body.stmts[2].kind;
- if let Some(ref init) = local1.init;
- if let ExprKind::Path(ref path8) = init.kind;
- if match_qpath(path8, &["__next"]);
- if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local1.pat.kind;
- if name1.as_str() == "y";
- if let StmtKind::Expr(ref e1, _) = body.stmts[3].kind
- if let ExprKind::Block(ref block) = e1.kind;
+ if let ExprKind::Block(ref block) = arms1[1].body.kind;
if block.stmts.len() == 1;
- if let StmtKind::Local(ref local2) = block.stmts[0].kind;
- if let Some(ref init1) = local2.init;
- if let ExprKind::Path(ref path9) = init1.kind;
- if match_qpath(path9, &["y"]);
- if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local2.pat.kind;
- if name2.as_str() == "z";
+ if let StmtKind::Local(ref local) = block.stmts[0].kind;
+ if let Some(ref init) = local.init;
+ if let ExprKind::Path(ref path5) = init.kind;
+ if match_qpath(path5, &["y"]);
+ if let PatKind::Binding(BindingAnnotation::Unannotated, _, name, None) = local.pat.kind;
+ if name.as_str() == "z";
if block.expr.is_none();
+ if let PatKind::Struct(ref path6, ref fields2, false) = arms1[1].pat.kind;
+ if matches!(path6, QPath::LangItem(LangItem::OptionSome, _));
+ if fields2.len() == 1;
+ // unimplemented: field checks
if body.expr.is_none();
- if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.kind;
- if name3.as_str() == "iter";
+ if let PatKind::Binding(BindingAnnotation::Mutable, _, name1, None) = arms[0].pat.kind;
+ if name1.as_str() == "iter";
then {
// report your lint here
}
-Subproject commit 73668334f05c3446b04116ccc3156240d2d8ab19
+Subproject commit 183ef048f61ae36aa389d1d0345cde940fe788e9
.then(out => {
const [output, nb_failures] = out;
results[nb_failures === 0 ? "successful" : "failed"].push({
- file_name: file_name,
+ file_name: testPath,
output: output,
});
if (nb_failures > 0) {
})
.catch(err => {
results.errored.push({
- file_name: file_name,
+ file_name: testPath + file_name,
output: err,
});
status_bar.erroneous();
console.log("");
results.failed.sort(by_filename);
results.failed.forEach(r => {
- console.log(r.output);
+ console.log(r.file_name, r.output);
});
}
if (results.errored.length > 0) {
// print run errors on the bottom so developers see them better
results.errored.sort(by_filename);
results.errored.forEach(r => {
- console.error(r.output);
+ console.error(r.file_name, r.output);
});
}
contains_ignore_directive(can_contain, &contents, "end-whitespace");
let mut skip_trailing_newlines =
contains_ignore_directive(can_contain, &contents, "trailing-newlines");
+ let mut skip_leading_newlines =
+ contains_ignore_directive(can_contain, &contents, "leading-newlines");
let mut skip_copyright = contains_ignore_directive(can_contain, &contents, "copyright");
let mut leading_new_lines = false;
let mut trailing_new_lines = 0;
}
}
if leading_new_lines {
- tidy_error!(bad, "{}: leading newline", file.display());
+ let mut err = |_| {
+ tidy_error!(bad, "{}: leading newline", file.display());
+ };
+ suppressible_tidy_err!(err, skip_leading_newlines, "mising leading newline");
}
let mut err = |msg: &str| {
tidy_error!(bad, "{}: {}", file.display(), msg);
if let Directive::Ignore(false) = skip_trailing_newlines {
tidy_error!(bad, "{}: ignoring trailing newlines unnecessarily", file.display());
}
+ if let Directive::Ignore(false) = skip_leading_newlines {
+ tidy_error!(bad, "{}: ignoring leading newlines unnecessarily", file.display());
+ }
if let Directive::Ignore(false) = skip_copyright {
tidy_error!(bad, "{}: ignoring copyright unnecessarily", file.display());
}
const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
-const ROOT_ENTRY_LIMIT: usize = 1102;
+const ROOT_ENTRY_LIMIT: usize = 983;
const ISSUES_ENTRY_LIMIT: usize = 2310;
-const PARSER_LIMIT: usize = 1005;
+const PARSER_LIMIT: usize = 1012;
fn check_entries(path: &Path, bad: &mut bool) {
let dirs = walkdir::WalkDir::new(&path.join("test/ui"))