authorbors <bors@rust-lang.org> 2025-08-08 20:53:33 UTC
committerbors <bors@rust-lang.org> 2025-08-08 20:53:33 UTC
logffb9d94dcf4ade0d534842be3672d5e9f47e1333
treefae25695be80c3e9e2f78b7e084763d52fe0462a
parentde3efa79f95852c7427587f1d535bfea7c0d6779
parent660bf919dc5dec96d319cce59702b0355bd8452c

Auto merge of #145126 - tgross35:rollup-6w87usd, r=tgross35

Rollup of 8 pull requests Successful merges: - rust-lang/rust#139451 (Add `target_env = "macabi"` and `target_env = "sim"`) - rust-lang/rust#144039 (Use `tcx.short_string()` in more diagnostics) - rust-lang/rust#144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend) - rust-lang/rust#144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses) - rust-lang/rust#144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697)) - rust-lang/rust#144649 (Account for bare tuples and `Pin` methods in field searching logic) - rust-lang/rust#144775 (more strongly dissuade use of `skip_binder`) - rust-lang/rust#144987 (Enable f16 and f128 on targets that were fixed in LLVM21) r? `@ghost` `@rustbot` modify labels: rollup

179 files changed, 1734 insertions(+), 791 deletions(-)

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs+12-12
......@@ -969,7 +969,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
969969
970970 let layout = amount.layout();
971971 match layout.ty.kind() {
972 ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
972 ty::Uint(_) | ty::Int(_) => {}
973973 _ => {
974974 report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
975975 return Ok(());
......@@ -982,7 +982,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
982982 let old =
983983 fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Add, ptr, amount);
984984
985 let old = CValue::by_val(old, layout);
985 let old = CValue::by_val(old, ret.layout());
986986 ret.write_cvalue(fx, old);
987987 }
988988 sym::atomic_xsub => {
......@@ -991,7 +991,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
991991
992992 let layout = amount.layout();
993993 match layout.ty.kind() {
994 ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
994 ty::Uint(_) | ty::Int(_) => {}
995995 _ => {
996996 report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
997997 return Ok(());
......@@ -1004,7 +1004,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10041004 let old =
10051005 fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Sub, ptr, amount);
10061006
1007 let old = CValue::by_val(old, layout);
1007 let old = CValue::by_val(old, ret.layout());
10081008 ret.write_cvalue(fx, old);
10091009 }
10101010 sym::atomic_and => {
......@@ -1013,7 +1013,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10131013
10141014 let layout = src.layout();
10151015 match layout.ty.kind() {
1016 ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
1016 ty::Uint(_) | ty::Int(_) => {}
10171017 _ => {
10181018 report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
10191019 return Ok(());
......@@ -1025,7 +1025,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10251025
10261026 let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::And, ptr, src);
10271027
1028 let old = CValue::by_val(old, layout);
1028 let old = CValue::by_val(old, ret.layout());
10291029 ret.write_cvalue(fx, old);
10301030 }
10311031 sym::atomic_or => {
......@@ -1034,7 +1034,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10341034
10351035 let layout = src.layout();
10361036 match layout.ty.kind() {
1037 ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
1037 ty::Uint(_) | ty::Int(_) => {}
10381038 _ => {
10391039 report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
10401040 return Ok(());
......@@ -1046,7 +1046,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10461046
10471047 let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Or, ptr, src);
10481048
1049 let old = CValue::by_val(old, layout);
1049 let old = CValue::by_val(old, ret.layout());
10501050 ret.write_cvalue(fx, old);
10511051 }
10521052 sym::atomic_xor => {
......@@ -1055,7 +1055,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10551055
10561056 let layout = src.layout();
10571057 match layout.ty.kind() {
1058 ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
1058 ty::Uint(_) | ty::Int(_) => {}
10591059 _ => {
10601060 report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
10611061 return Ok(());
......@@ -1067,7 +1067,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10671067
10681068 let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Xor, ptr, src);
10691069
1070 let old = CValue::by_val(old, layout);
1070 let old = CValue::by_val(old, ret.layout());
10711071 ret.write_cvalue(fx, old);
10721072 }
10731073 sym::atomic_nand => {
......@@ -1076,7 +1076,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10761076
10771077 let layout = src.layout();
10781078 match layout.ty.kind() {
1079 ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
1079 ty::Uint(_) | ty::Int(_) => {}
10801080 _ => {
10811081 report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
10821082 return Ok(());
......@@ -1088,7 +1088,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
10881088
10891089 let old = fx.bcx.ins().atomic_rmw(ty, MemFlags::trusted(), AtomicRmwOp::Nand, ptr, src);
10901090
1091 let old = CValue::by_val(old, layout);
1091 let old = CValue::by_val(old, ret.layout());
10921092 ret.write_cvalue(fx, old);
10931093 }
10941094 sym::atomic_max => {
compiler/rustc_codegen_gcc/src/builder.rs+6-1
......@@ -1671,6 +1671,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
16711671 dst: RValue<'gcc>,
16721672 src: RValue<'gcc>,
16731673 order: AtomicOrdering,
1674 ret_ptr: bool,
16741675 ) -> RValue<'gcc> {
16751676 let size = get_maybe_pointer_size(src);
16761677 let name = match op {
......@@ -1698,6 +1699,9 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
16981699 let atomic_function = self.context.get_builtin_function(name);
16991700 let order = self.context.new_rvalue_from_int(self.i32_type, order.to_gcc());
17001701
1702 // FIXME: If `ret_ptr` is true and `src` is an integer, we should really tell GCC
1703 // that this is a pointer operation that needs to preserve provenance -- but like LLVM,
1704 // GCC does not currently seems to support that.
17011705 let void_ptr_type = self.context.new_type::<*mut ()>();
17021706 let volatile_void_ptr_type = void_ptr_type.make_volatile();
17031707 let dst = self.context.new_cast(self.location, dst, volatile_void_ptr_type);
......@@ -1705,7 +1709,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
17051709 let new_src_type = atomic_function.get_param(1).to_rvalue().get_type();
17061710 let src = self.context.new_bitcast(self.location, src, new_src_type);
17071711 let res = self.context.new_call(self.location, atomic_function, &[dst, src, order]);
1708 self.context.new_cast(self.location, res, src.get_type())
1712 let res_type = if ret_ptr { void_ptr_type } else { src.get_type() };
1713 self.context.new_cast(self.location, res, res_type)
17091714 }
17101715
17111716 fn atomic_fence(&mut self, order: AtomicOrdering, scope: SynchronizationScope) {
compiler/rustc_codegen_llvm/src/builder.rs+6-8
......@@ -1327,15 +1327,13 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
13271327 &mut self,
13281328 op: rustc_codegen_ssa::common::AtomicRmwBinOp,
13291329 dst: &'ll Value,
1330 mut src: &'ll Value,
1330 src: &'ll Value,
13311331 order: rustc_middle::ty::AtomicOrdering,
1332 ret_ptr: bool,
13321333 ) -> &'ll Value {
1333 // The only RMW operation that LLVM supports on pointers is compare-exchange.
1334 let requires_cast_to_int = self.val_ty(src) == self.type_ptr()
1335 && op != rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg;
1336 if requires_cast_to_int {
1337 src = self.ptrtoint(src, self.type_isize());
1338 }
1334 // FIXME: If `ret_ptr` is true and `src` is not a pointer, we *should* tell LLVM that the
1335 // LHS is a pointer and the operation should be provenance-preserving, but LLVM does not
1336 // currently support that (https://github.com/llvm/llvm-project/issues/120837).
13391337 let mut res = unsafe {
13401338 llvm::LLVMBuildAtomicRMW(
13411339 self.llbuilder,
......@@ -1346,7 +1344,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
13461344 llvm::False, // SingleThreaded
13471345 )
13481346 };
1349 if requires_cast_to_int {
1347 if ret_ptr && self.val_ty(res) != self.type_ptr() {
13501348 res = self.inttoptr(res, self.type_ptr());
13511349 }
13521350 res
compiler/rustc_codegen_llvm/src/llvm_util.rs+13-11
......@@ -377,24 +377,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
377377 let target_abi = sess.target.options.abi.as_ref();
378378 let target_pointer_width = sess.target.pointer_width;
379379 let version = get_version();
380 let lt_20_1_1 = version < (20, 1, 1);
381 let lt_21_0_0 = version < (21, 0, 0);
380382
381383 cfg.has_reliable_f16 = match (target_arch, target_os) {
382 // Selection failure <https://github.com/llvm/llvm-project/issues/50374>
383 ("s390x", _) => false,
384 // LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (now fixed)
384 // LLVM crash without neon <https://github.com/llvm/llvm-project/issues/129394> (fixed in llvm20)
385385 ("aarch64", _)
386 if !cfg.target_features.iter().any(|f| f.as_str() == "neon")
387 && version < (20, 1, 1) =>
386 if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 =>
388387 {
389388 false
390389 }
391390 // Unsupported <https://github.com/llvm/llvm-project/issues/94434>
392391 ("arm64ec", _) => false,
392 // Selection failure <https://github.com/llvm/llvm-project/issues/50374> (fixed in llvm21)
393 ("s390x", _) if lt_21_0_0 => false,
393394 // MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
394395 ("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
395396 // Infinite recursion <https://github.com/llvm/llvm-project/issues/97981>
396397 ("csky", _) => false,
397 ("hexagon", _) => false,
398 ("hexagon", _) if lt_21_0_0 => false, // (fixed in llvm21)
398399 ("powerpc" | "powerpc64", _) => false,
399400 ("sparc" | "sparc64", _) => false,
400401 ("wasm32" | "wasm64", _) => false,
......@@ -407,9 +408,10 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
407408 cfg.has_reliable_f128 = match (target_arch, target_os) {
408409 // Unsupported <https://github.com/llvm/llvm-project/issues/94434>
409410 ("arm64ec", _) => false,
410 // Selection bug <https://github.com/llvm/llvm-project/issues/96432>
411 ("mips64" | "mips64r6", _) => false,
412 // Selection bug <https://github.com/llvm/llvm-project/issues/95471>
411 // Selection bug <https://github.com/llvm/llvm-project/issues/96432> (fixed in llvm20)
412 ("mips64" | "mips64r6", _) if lt_20_1_1 => false,
413 // Selection bug <https://github.com/llvm/llvm-project/issues/95471>. This issue is closed
414 // but basic math still does not work.
413415 ("nvptx64", _) => false,
414416 // Unsupported https://github.com/llvm/llvm-project/issues/121122
415417 ("amdgpu", _) => false,
......@@ -419,8 +421,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
419421 // ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
420422 ("sparc", _) => false,
421423 // Stack alignment bug <https://github.com/llvm/llvm-project/issues/77401>. NB: tests may
422 // not fail if our compiler-builtins is linked.
423 ("x86", _) => false,
424 // not fail if our compiler-builtins is linked. (fixed in llvm21)
425 ("x86", _) if lt_21_0_0 => false,
424426 // MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
425427 ("x86_64", "windows") if target_env == "gnu" && target_abi != "llvm" => false,
426428 // There are no known problems on other platforms, so the only requirement is that symbols
compiler/rustc_codegen_ssa/messages.ftl+2
......@@ -101,6 +101,8 @@ codegen_ssa_invalid_monomorphization_basic_float_type = invalid monomorphization
101101
102102codegen_ssa_invalid_monomorphization_basic_integer_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
103103
104codegen_ssa_invalid_monomorphization_basic_integer_or_ptr_type = invalid monomorphization of `{$name}` intrinsic: expected basic integer or pointer type, found `{$ty}`
105
104106codegen_ssa_invalid_monomorphization_cannot_return = invalid monomorphization of `{$name}` intrinsic: cannot return `{$ret_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
105107
106108codegen_ssa_invalid_monomorphization_cast_wide_pointer = invalid monomorphization of `{$name}` intrinsic: cannot cast wide pointer `{$ty}`
compiler/rustc_codegen_ssa/src/back/apple.rs+2-2
......@@ -17,7 +17,7 @@ mod tests;
1717
1818/// The canonical name of the desired SDK for a given target.
1919pub(super) fn sdk_name(target: &Target) -> &'static str {
20 match (&*target.os, &*target.abi) {
20 match (&*target.os, &*target.env) {
2121 ("macos", "") => "MacOSX",
2222 ("ios", "") => "iPhoneOS",
2323 ("ios", "sim") => "iPhoneSimulator",
......@@ -34,7 +34,7 @@ pub(super) fn sdk_name(target: &Target) -> &'static str {
3434}
3535
3636pub(super) fn macho_platform(target: &Target) -> u32 {
37 match (&*target.os, &*target.abi) {
37 match (&*target.os, &*target.env) {
3838 ("macos", _) => object::macho::PLATFORM_MACOS,
3939 ("ios", "macabi") => object::macho::PLATFORM_MACCATALYST,
4040 ("ios", "sim") => object::macho::PLATFORM_IOSSIMULATOR,
compiler/rustc_codegen_ssa/src/back/link.rs+4-4
......@@ -3026,7 +3026,7 @@ pub(crate) fn are_upstream_rust_objects_already_included(sess: &Session) -> bool
30263026/// We need to communicate five things to the linker on Apple/Darwin targets:
30273027/// - The architecture.
30283028/// - The operating system (and that it's an Apple platform).
3029/// - The environment / ABI.
3029/// - The environment.
30303030/// - The deployment target.
30313031/// - The SDK version.
30323032fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
......@@ -3040,7 +3040,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
30403040 // `sess.target.arch` (`target_arch`) is not detailed enough.
30413041 let llvm_arch = sess.target.llvm_target.split_once('-').expect("LLVM target must have arch").0;
30423042 let target_os = &*sess.target.os;
3043 let target_abi = &*sess.target.abi;
3043 let target_env = &*sess.target.env;
30443044
30453045 // The architecture name to forward to the linker.
30463046 //
......@@ -3091,14 +3091,14 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
30913091 // > - visionos-simulator
30923092 // > - xros-simulator
30933093 // > - driverkit
3094 let platform_name = match (target_os, target_abi) {
3094 let platform_name = match (target_os, target_env) {
30953095 (os, "") => os,
30963096 ("ios", "macabi") => "mac-catalyst",
30973097 ("ios", "sim") => "ios-simulator",
30983098 ("tvos", "sim") => "tvos-simulator",
30993099 ("watchos", "sim") => "watchos-simulator",
31003100 ("visionos", "sim") => "visionos-simulator",
3101 _ => bug!("invalid OS/ABI combination for Apple target: {target_os}, {target_abi}"),
3101 _ => bug!("invalid OS/env combination for Apple target: {target_os}, {target_env}"),
31023102 };
31033103
31043104 let min_version = sess.apple_deployment_target().fmt_full().to_string();
compiler/rustc_codegen_ssa/src/errors.rs+8
......@@ -764,6 +764,14 @@ pub enum InvalidMonomorphization<'tcx> {
764764 ty: Ty<'tcx>,
765765 },
766766
767 #[diag(codegen_ssa_invalid_monomorphization_basic_integer_or_ptr_type, code = E0511)]
768 BasicIntegerOrPtrType {
769 #[primary_span]
770 span: Span,
771 name: Symbol,
772 ty: Ty<'tcx>,
773 },
774
767775 #[diag(codegen_ssa_invalid_monomorphization_basic_float_type, code = E0511)]
768776 BasicFloatType {
769777 #[primary_span]
compiler/rustc_codegen_ssa/src/mir/intrinsic.rs+66-16
......@@ -92,6 +92,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
9292 let invalid_monomorphization_int_type = |ty| {
9393 bx.tcx().dcx().emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty });
9494 };
95 let invalid_monomorphization_int_or_ptr_type = |ty| {
96 bx.tcx().dcx().emit_err(InvalidMonomorphization::BasicIntegerOrPtrType {
97 span,
98 name,
99 ty,
100 });
101 };
95102
96103 let parse_atomic_ordering = |ord: ty::Value<'tcx>| {
97104 let discr = ord.valtree.unwrap_branch()[0].unwrap_leaf();
......@@ -351,7 +358,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
351358 sym::atomic_load => {
352359 let ty = fn_args.type_at(0);
353360 if !(int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr()) {
354 invalid_monomorphization_int_type(ty);
361 invalid_monomorphization_int_or_ptr_type(ty);
355362 return Ok(());
356363 }
357364 let ordering = fn_args.const_at(1).to_value();
......@@ -367,7 +374,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
367374 sym::atomic_store => {
368375 let ty = fn_args.type_at(0);
369376 if !(int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr()) {
370 invalid_monomorphization_int_type(ty);
377 invalid_monomorphization_int_or_ptr_type(ty);
371378 return Ok(());
372379 }
373380 let ordering = fn_args.const_at(1).to_value();
......@@ -377,10 +384,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
377384 bx.atomic_store(val, ptr, parse_atomic_ordering(ordering), size);
378385 return Ok(());
379386 }
387 // These are all AtomicRMW ops
380388 sym::atomic_cxchg | sym::atomic_cxchgweak => {
381389 let ty = fn_args.type_at(0);
382390 if !(int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr()) {
383 invalid_monomorphization_int_type(ty);
391 invalid_monomorphization_int_or_ptr_type(ty);
384392 return Ok(());
385393 }
386394 let succ_ordering = fn_args.const_at(1).to_value();
......@@ -407,7 +415,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
407415
408416 return Ok(());
409417 }
410 // These are all AtomicRMW ops
411418 sym::atomic_max | sym::atomic_min => {
412419 let atom_op = if name == sym::atomic_max {
413420 AtomicRmwBinOp::AtomicMax
......@@ -420,7 +427,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
420427 let ordering = fn_args.const_at(1).to_value();
421428 let ptr = args[0].immediate();
422429 let val = args[1].immediate();
423 bx.atomic_rmw(atom_op, ptr, val, parse_atomic_ordering(ordering))
430 bx.atomic_rmw(
431 atom_op,
432 ptr,
433 val,
434 parse_atomic_ordering(ordering),
435 /* ret_ptr */ false,
436 )
424437 } else {
425438 invalid_monomorphization_int_type(ty);
426439 return Ok(());
......@@ -438,21 +451,44 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
438451 let ordering = fn_args.const_at(1).to_value();
439452 let ptr = args[0].immediate();
440453 let val = args[1].immediate();
441 bx.atomic_rmw(atom_op, ptr, val, parse_atomic_ordering(ordering))
454 bx.atomic_rmw(
455 atom_op,
456 ptr,
457 val,
458 parse_atomic_ordering(ordering),
459 /* ret_ptr */ false,
460 )
442461 } else {
443462 invalid_monomorphization_int_type(ty);
444463 return Ok(());
445464 }
446465 }
447 sym::atomic_xchg
448 | sym::atomic_xadd
466 sym::atomic_xchg => {
467 let ty = fn_args.type_at(0);
468 let ordering = fn_args.const_at(1).to_value();
469 if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
470 let ptr = args[0].immediate();
471 let val = args[1].immediate();
472 let atomic_op = AtomicRmwBinOp::AtomicXchg;
473 bx.atomic_rmw(
474 atomic_op,
475 ptr,
476 val,
477 parse_atomic_ordering(ordering),
478 /* ret_ptr */ ty.is_raw_ptr(),
479 )
480 } else {
481 invalid_monomorphization_int_or_ptr_type(ty);
482 return Ok(());
483 }
484 }
485 sym::atomic_xadd
449486 | sym::atomic_xsub
450487 | sym::atomic_and
451488 | sym::atomic_nand
452489 | sym::atomic_or
453490 | sym::atomic_xor => {
454491 let atom_op = match name {
455 sym::atomic_xchg => AtomicRmwBinOp::AtomicXchg,
456492 sym::atomic_xadd => AtomicRmwBinOp::AtomicAdd,
457493 sym::atomic_xsub => AtomicRmwBinOp::AtomicSub,
458494 sym::atomic_and => AtomicRmwBinOp::AtomicAnd,
......@@ -462,14 +498,28 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
462498 _ => unreachable!(),
463499 };
464500
465 let ty = fn_args.type_at(0);
466 if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
467 let ordering = fn_args.const_at(1).to_value();
468 let ptr = args[0].immediate();
469 let val = args[1].immediate();
470 bx.atomic_rmw(atom_op, ptr, val, parse_atomic_ordering(ordering))
501 // The type of the in-memory data.
502 let ty_mem = fn_args.type_at(0);
503 // The type of the 2nd operand, given by-value.
504 let ty_op = fn_args.type_at(1);
505
506 let ordering = fn_args.const_at(2).to_value();
507 // We require either both arguments to have the same integer type, or the first to
508 // be a pointer and the second to be `usize`.
509 if (int_type_width_signed(ty_mem, bx.tcx()).is_some() && ty_op == ty_mem)
510 || (ty_mem.is_raw_ptr() && ty_op == bx.tcx().types.usize)
511 {
512 let ptr = args[0].immediate(); // of type "pointer to `ty_mem`"
513 let val = args[1].immediate(); // of type `ty_op`
514 bx.atomic_rmw(
515 atom_op,
516 ptr,
517 val,
518 parse_atomic_ordering(ordering),
519 /* ret_ptr */ ty_mem.is_raw_ptr(),
520 )
471521 } else {
472 invalid_monomorphization_int_type(ty);
522 invalid_monomorphization_int_or_ptr_type(ty_mem);
473523 return Ok(());
474524 }
475525 }
compiler/rustc_codegen_ssa/src/traits/builder.rs+3
......@@ -548,12 +548,15 @@ pub trait BuilderMethods<'a, 'tcx>:
548548 failure_order: AtomicOrdering,
549549 weak: bool,
550550 ) -> (Self::Value, Self::Value);
551 /// `ret_ptr` indicates whether the return type (which is also the type `dst` points to)
552 /// is a pointer or the same type as `src`.
551553 fn atomic_rmw(
552554 &mut self,
553555 op: AtomicRmwBinOp,
554556 dst: Self::Value,
555557 src: Self::Value,
556558 order: AtomicOrdering,
559 ret_ptr: bool,
557560 ) -> Self::Value;
558561 fn atomic_fence(&mut self, order: AtomicOrdering, scope: SynchronizationScope);
559562 fn set_invariant_load(&mut self, load: Self::Value);
compiler/rustc_errors/src/diagnostic.rs+5
......@@ -1382,6 +1382,11 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
13821382 &mut self.long_ty_path
13831383 }
13841384
1385 pub fn with_long_ty_path(mut self, long_ty_path: Option<PathBuf>) -> Self {
1386 self.long_ty_path = long_ty_path;
1387 self
1388 }
1389
13851390 /// Most `emit_producing_guarantee` functions use this as a starting point.
13861391 fn emit_producing_nothing(mut self) {
13871392 let diag = self.take_diag();
compiler/rustc_errors/src/emitter.rs+1-1
......@@ -409,7 +409,7 @@ pub trait Emitter {
409409 if !redundant_span || always_backtrace {
410410 let msg: Cow<'static, _> = match trace.kind {
411411 ExpnKind::Macro(MacroKind::Attr, _) => {
412 "this procedural macro expansion".into()
412 "this attribute macro expansion".into()
413413 }
414414 ExpnKind::Macro(MacroKind::Derive, _) => {
415415 "this derive macro expansion".into()
compiler/rustc_expand/messages.ftl+3
......@@ -70,6 +70,9 @@ expand_invalid_fragment_specifier =
7070 invalid fragment specifier `{$fragment}`
7171 .help = {$help}
7272
73expand_macro_args_bad_delim = macro attribute argument matchers require parentheses
74expand_macro_args_bad_delim_sugg = the delimiters should be `(` and `)`
75
7376expand_macro_body_stability =
7477 macros cannot have body stability attributes
7578 .label = invalid body stability attribute
compiler/rustc_expand/src/errors.rs+18
......@@ -482,3 +482,21 @@ mod metavar_exprs {
482482 pub key: MacroRulesNormalizedIdent,
483483 }
484484}
485
486#[derive(Diagnostic)]
487#[diag(expand_macro_args_bad_delim)]
488pub(crate) struct MacroArgsBadDelim {
489 #[primary_span]
490 pub span: Span,
491 #[subdiagnostic]
492 pub sugg: MacroArgsBadDelimSugg,
493}
494
495#[derive(Subdiagnostic)]
496#[multipart_suggestion(expand_macro_args_bad_delim_sugg, applicability = "machine-applicable")]
497pub(crate) struct MacroArgsBadDelimSugg {
498 #[suggestion_part(code = "(")]
499 pub open: Span,
500 #[suggestion_part(code = ")")]
501 pub close: Span,
502}
compiler/rustc_expand/src/mbe/diagnostics.rs+41-14
......@@ -7,29 +7,40 @@ use rustc_macros::Subdiagnostic;
77use rustc_parse::parser::{Parser, Recovery, token_descr};
88use rustc_session::parse::ParseSess;
99use rustc_span::source_map::SourceMap;
10use rustc_span::{ErrorGuaranteed, Ident, Span};
10use rustc_span::{DUMMY_SP, ErrorGuaranteed, Ident, Span};
1111use tracing::debug;
1212
1313use super::macro_rules::{MacroRule, NoopTracker, parser_from_cx};
1414use crate::expand::{AstFragmentKind, parse_ast_fragment};
1515use crate::mbe::macro_parser::ParseResult::*;
1616use crate::mbe::macro_parser::{MatcherLoc, NamedParseResult, TtParser};
17use crate::mbe::macro_rules::{Tracker, try_match_macro};
17use crate::mbe::macro_rules::{Tracker, try_match_macro, try_match_macro_attr};
1818
1919pub(super) fn failed_to_match_macro(
2020 psess: &ParseSess,
2121 sp: Span,
2222 def_span: Span,
2323 name: Ident,
24 arg: TokenStream,
24 attr_args: Option<&TokenStream>,
25 body: &TokenStream,
2526 rules: &[MacroRule],
2627) -> (Span, ErrorGuaranteed) {
2728 debug!("failed to match macro");
29 let def_head_span = if !def_span.is_dummy() && !psess.source_map().is_imported(def_span) {
30 psess.source_map().guess_head_span(def_span)
31 } else {
32 DUMMY_SP
33 };
34
2835 // An error occurred, try the expansion again, tracking the expansion closely for better
2936 // diagnostics.
3037 let mut tracker = CollectTrackerAndEmitter::new(psess.dcx(), sp);
3138
32 let try_success_result = try_match_macro(psess, name, &arg, rules, &mut tracker);
39 let try_success_result = if let Some(attr_args) = attr_args {
40 try_match_macro_attr(psess, name, attr_args, body, rules, &mut tracker)
41 } else {
42 try_match_macro(psess, name, body, rules, &mut tracker)
43 };
3344
3445 if try_success_result.is_ok() {
3546 // Nonterminal parser recovery might turn failed matches into successful ones,
......@@ -47,6 +58,18 @@ pub(super) fn failed_to_match_macro(
4758
4859 let Some(BestFailure { token, msg: label, remaining_matcher, .. }) = tracker.best_failure
4960 else {
61 // FIXME: we should report this at macro resolution time, as we do for
62 // `resolve_macro_cannot_use_as_attr`. We can do that once we track multiple macro kinds for a
63 // Def.
64 if attr_args.is_none() && !rules.iter().any(|rule| matches!(rule, MacroRule::Func { .. })) {
65 let msg = format!("macro has no rules for function-like invocation `{name}!`");
66 let mut err = psess.dcx().struct_span_err(sp, msg);
67 if !def_head_span.is_dummy() {
68 let msg = "this macro has no rules for function-like invocation";
69 err.span_label(def_head_span, msg);
70 }
71 return (sp, err.emit());
72 }
5073 return (sp, psess.dcx().span_delayed_bug(sp, "failed to match a macro"));
5174 };
5275
......@@ -54,8 +77,8 @@ pub(super) fn failed_to_match_macro(
5477
5578 let mut err = psess.dcx().struct_span_err(span, parse_failure_msg(&token, None));
5679 err.span_label(span, label);
57 if !def_span.is_dummy() && !psess.source_map().is_imported(def_span) {
58 err.span_label(psess.source_map().guess_head_span(def_span), "when calling this macro");
80 if !def_head_span.is_dummy() {
81 err.span_label(def_head_span, "when calling this macro");
5982 }
6083
6184 annotate_doc_comment(&mut err, psess.source_map(), span);
......@@ -79,13 +102,16 @@ pub(super) fn failed_to_match_macro(
79102 }
80103
81104 // Check whether there's a missing comma in this macro call, like `println!("{}" a);`
82 if let Some((arg, comma_span)) = arg.add_comma() {
105 if attr_args.is_none()
106 && let Some((body, comma_span)) = body.add_comma()
107 {
83108 for rule in rules {
84 let parser = parser_from_cx(psess, arg.clone(), Recovery::Allowed);
109 let MacroRule::Func { lhs, .. } = rule else { continue };
110 let parser = parser_from_cx(psess, body.clone(), Recovery::Allowed);
85111 let mut tt_parser = TtParser::new(name);
86112
87113 if let Success(_) =
88 tt_parser.parse_tt(&mut Cow::Borrowed(&parser), &rule.lhs, &mut NoopTracker)
114 tt_parser.parse_tt(&mut Cow::Borrowed(&parser), lhs, &mut NoopTracker)
89115 {
90116 if comma_span.is_dummy() {
91117 err.note("you might be missing a comma");
......@@ -116,13 +142,13 @@ struct CollectTrackerAndEmitter<'dcx, 'matcher> {
116142
117143struct BestFailure {
118144 token: Token,
119 position_in_tokenstream: u32,
145 position_in_tokenstream: (bool, u32),
120146 msg: &'static str,
121147 remaining_matcher: MatcherLoc,
122148}
123149
124150impl BestFailure {
125 fn is_better_position(&self, position: u32) -> bool {
151 fn is_better_position(&self, position: (bool, u32)) -> bool {
126152 position > self.position_in_tokenstream
127153 }
128154}
......@@ -142,7 +168,7 @@ impl<'dcx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'dcx, 'match
142168 }
143169 }
144170
145 fn after_arm(&mut self, result: &NamedParseResult<Self::Failure>) {
171 fn after_arm(&mut self, in_body: bool, result: &NamedParseResult<Self::Failure>) {
146172 match result {
147173 Success(_) => {
148174 // Nonterminal parser recovery might turn failed matches into successful ones,
......@@ -155,14 +181,15 @@ impl<'dcx, 'matcher> Tracker<'matcher> for CollectTrackerAndEmitter<'dcx, 'match
155181 Failure((token, approx_position, msg)) => {
156182 debug!(?token, ?msg, "a new failure of an arm");
157183
184 let position_in_tokenstream = (in_body, *approx_position);
158185 if self
159186 .best_failure
160187 .as_ref()
161 .is_none_or(|failure| failure.is_better_position(*approx_position))
188 .is_none_or(|failure| failure.is_better_position(position_in_tokenstream))
162189 {
163190 self.best_failure = Some(BestFailure {
164191 token: *token,
165 position_in_tokenstream: *approx_position,
192 position_in_tokenstream,
166193 msg,
167194 remaining_matcher: self
168195 .remaining_matcher
compiler/rustc_expand/src/mbe/macro_check.rs+5-1
......@@ -193,15 +193,19 @@ struct MacroState<'a> {
193193/// Arguments:
194194/// - `psess` is used to emit diagnostics and lints
195195/// - `node_id` is used to emit lints
196/// - `lhs` and `rhs` represent the rule
196/// - `args`, `lhs`, and `rhs` represent the rule
197197pub(super) fn check_meta_variables(
198198 psess: &ParseSess,
199199 node_id: NodeId,
200 args: Option<&TokenTree>,
200201 lhs: &TokenTree,
201202 rhs: &TokenTree,
202203) -> Result<(), ErrorGuaranteed> {
203204 let mut guar = None;
204205 let mut binders = Binders::default();
206 if let Some(args) = args {
207 check_binders(psess, node_id, args, &Stack::Empty, &mut binders, &Stack::Empty, &mut guar);
208 }
205209 check_binders(psess, node_id, lhs, &Stack::Empty, &mut binders, &Stack::Empty, &mut guar);
206210 check_occurrences(psess, node_id, rhs, &Stack::Empty, &binders, &Stack::Empty, &mut guar);
207211 guar.map_or(Ok(()), Err)
compiler/rustc_expand/src/mbe/macro_rules.rs+234-30
......@@ -6,12 +6,12 @@ use std::{mem, slice};
66use ast::token::IdentIsRaw;
77use rustc_ast::token::NtPatKind::*;
88use rustc_ast::token::TokenKind::*;
9use rustc_ast::token::{self, NonterminalKind, Token, TokenKind};
10use rustc_ast::tokenstream::{DelimSpan, TokenStream};
9use rustc_ast::token::{self, Delimiter, NonterminalKind, Token, TokenKind};
10use rustc_ast::tokenstream::{self, DelimSpan, TokenStream};
1111use rustc_ast::{self as ast, DUMMY_NODE_ID, NodeId};
1212use rustc_ast_pretty::pprust;
1313use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
14use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
14use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan};
1515use rustc_feature::Features;
1616use rustc_hir as hir;
1717use rustc_hir::attrs::AttributeKind;
......@@ -23,23 +23,26 @@ use rustc_lint_defs::builtin::{
2323use rustc_parse::exp;
2424use rustc_parse::parser::{Parser, Recovery};
2525use rustc_session::Session;
26use rustc_session::parse::ParseSess;
26use rustc_session::parse::{ParseSess, feature_err};
2727use rustc_span::edition::Edition;
2828use rustc_span::hygiene::Transparency;
2929use rustc_span::{Ident, Span, kw, sym};
3030use tracing::{debug, instrument, trace, trace_span};
3131
32use super::diagnostics::failed_to_match_macro;
3233use super::macro_parser::{NamedMatches, NamedParseResult};
3334use super::{SequenceRepetition, diagnostics};
3435use crate::base::{
35 DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult, SyntaxExtension,
36 SyntaxExtensionKind, TTMacroExpander,
36 AttrProcMacro, DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult,
37 SyntaxExtension, SyntaxExtensionKind, TTMacroExpander,
3738};
39use crate::errors;
3840use crate::expand::{AstFragment, AstFragmentKind, ensure_complete_parse, parse_ast_fragment};
41use crate::mbe::macro_check::check_meta_variables;
3942use crate::mbe::macro_parser::{Error, ErrorReported, Failure, MatcherLoc, Success, TtParser};
4043use crate::mbe::quoted::{RulePart, parse_one_tt};
4144use crate::mbe::transcribe::transcribe;
42use crate::mbe::{self, KleeneOp, macro_check};
45use crate::mbe::{self, KleeneOp};
4346
4447pub(crate) struct ParserAnyMacro<'a> {
4548 parser: Parser<'a>,
......@@ -123,10 +126,17 @@ impl<'a> ParserAnyMacro<'a> {
123126 }
124127}
125128
126pub(super) struct MacroRule {
127 pub(super) lhs: Vec<MatcherLoc>,
128 lhs_span: Span,
129 rhs: mbe::TokenTree,
129pub(super) enum MacroRule {
130 /// A function-style rule, for use with `m!()`
131 Func { lhs: Vec<MatcherLoc>, lhs_span: Span, rhs: mbe::TokenTree },
132 /// An attr rule, for use with `#[m]`
133 Attr {
134 args: Vec<MatcherLoc>,
135 args_span: Span,
136 body: Vec<MatcherLoc>,
137 body_span: Span,
138 rhs: mbe::TokenTree,
139 },
130140}
131141
132142pub struct MacroRulesMacroExpander {
......@@ -138,10 +148,15 @@ pub struct MacroRulesMacroExpander {
138148}
139149
140150impl MacroRulesMacroExpander {
141 pub fn get_unused_rule(&self, rule_i: usize) -> Option<(&Ident, Span)> {
151 pub fn get_unused_rule(&self, rule_i: usize) -> Option<(&Ident, MultiSpan)> {
142152 // If the rhs contains an invocation like `compile_error!`, don't report it as unused.
143 let rule = &self.rules[rule_i];
144 if has_compile_error_macro(&rule.rhs) { None } else { Some((&self.name, rule.lhs_span)) }
153 let (span, rhs) = match self.rules[rule_i] {
154 MacroRule::Func { lhs_span, ref rhs, .. } => (MultiSpan::from_span(lhs_span), rhs),
155 MacroRule::Attr { args_span, body_span, ref rhs, .. } => {
156 (MultiSpan::from_spans(vec![args_span, body_span]), rhs)
157 }
158 };
159 if has_compile_error_macro(rhs) { None } else { Some((&self.name, span)) }
145160 }
146161}
147162
......@@ -165,6 +180,28 @@ impl TTMacroExpander for MacroRulesMacroExpander {
165180 }
166181}
167182
183impl AttrProcMacro for MacroRulesMacroExpander {
184 fn expand(
185 &self,
186 cx: &mut ExtCtxt<'_>,
187 sp: Span,
188 args: TokenStream,
189 body: TokenStream,
190 ) -> Result<TokenStream, ErrorGuaranteed> {
191 expand_macro_attr(
192 cx,
193 sp,
194 self.span,
195 self.node_id,
196 self.name,
197 self.transparency,
198 args,
199 body,
200 &self.rules,
201 )
202 }
203}
204
168205struct DummyExpander(ErrorGuaranteed);
169206
170207impl TTMacroExpander for DummyExpander {
......@@ -197,7 +234,7 @@ pub(super) trait Tracker<'matcher> {
197234
198235 /// This is called after an arm has been parsed, either successfully or unsuccessfully. When
199236 /// this is called, `before_match_loc` was called at least once (with a `MatcherLoc::Eof`).
200 fn after_arm(&mut self, _result: &NamedParseResult<Self::Failure>) {}
237 fn after_arm(&mut self, _in_body: bool, _result: &NamedParseResult<Self::Failure>) {}
201238
202239 /// For tracing.
203240 fn description() -> &'static str;
......@@ -245,14 +282,17 @@ fn expand_macro<'cx>(
245282
246283 match try_success_result {
247284 Ok((rule_index, rule, named_matches)) => {
248 let mbe::TokenTree::Delimited(rhs_span, _, ref rhs) = rule.rhs else {
285 let MacroRule::Func { rhs, .. } = rule else {
286 panic!("try_match_macro returned non-func rule");
287 };
288 let mbe::TokenTree::Delimited(rhs_span, _, rhs) = rhs else {
249289 cx.dcx().span_bug(sp, "malformed macro rhs");
250290 };
251 let arm_span = rule.rhs.span();
291 let arm_span = rhs_span.entire();
252292
253293 // rhs has holes ( `$id` and `$(...)` that need filled)
254294 let id = cx.current_expansion.id;
255 let tts = match transcribe(psess, &named_matches, rhs, rhs_span, transparency, id) {
295 let tts = match transcribe(psess, &named_matches, rhs, *rhs_span, transparency, id) {
256296 Ok(tts) => tts,
257297 Err(err) => {
258298 let guar = err.emit();
......@@ -280,13 +320,76 @@ fn expand_macro<'cx>(
280320 Err(CanRetry::Yes) => {
281321 // Retry and emit a better error.
282322 let (span, guar) =
283 diagnostics::failed_to_match_macro(cx.psess(), sp, def_span, name, arg, rules);
323 failed_to_match_macro(cx.psess(), sp, def_span, name, None, &arg, rules);
284324 cx.macro_error_and_trace_macros_diag();
285325 DummyResult::any(span, guar)
286326 }
287327 }
288328}
289329
330/// Expands the rules based macro defined by `rules` for a given attribute `args` and `body`.
331#[instrument(skip(cx, transparency, args, body, rules))]
332fn expand_macro_attr(
333 cx: &mut ExtCtxt<'_>,
334 sp: Span,
335 def_span: Span,
336 node_id: NodeId,
337 name: Ident,
338 transparency: Transparency,
339 args: TokenStream,
340 body: TokenStream,
341 rules: &[MacroRule],
342) -> Result<TokenStream, ErrorGuaranteed> {
343 let psess = &cx.sess.psess;
344 // Macros defined in the current crate have a real node id,
345 // whereas macros from an external crate have a dummy id.
346 let is_local = node_id != DUMMY_NODE_ID;
347
348 if cx.trace_macros() {
349 let msg = format!(
350 "expanding `$[{name}({})] {}`",
351 pprust::tts_to_string(&args),
352 pprust::tts_to_string(&body),
353 );
354 trace_macros_note(&mut cx.expansions, sp, msg);
355 }
356
357 // Track nothing for the best performance.
358 match try_match_macro_attr(psess, name, &args, &body, rules, &mut NoopTracker) {
359 Ok((i, rule, named_matches)) => {
360 let MacroRule::Attr { rhs, .. } = rule else {
361 panic!("try_macro_match_attr returned non-attr rule");
362 };
363 let mbe::TokenTree::Delimited(rhs_span, _, rhs) = rhs else {
364 cx.dcx().span_bug(sp, "malformed macro rhs");
365 };
366
367 let id = cx.current_expansion.id;
368 let tts = transcribe(psess, &named_matches, rhs, *rhs_span, transparency, id)
369 .map_err(|e| e.emit())?;
370
371 if cx.trace_macros() {
372 let msg = format!("to `{}`", pprust::tts_to_string(&tts));
373 trace_macros_note(&mut cx.expansions, sp, msg);
374 }
375
376 if is_local {
377 cx.resolver.record_macro_rule_usage(node_id, i);
378 }
379
380 Ok(tts)
381 }
382 Err(CanRetry::No(guar)) => Err(guar),
383 Err(CanRetry::Yes) => {
384 // Retry and emit a better error.
385 let (_, guar) =
386 failed_to_match_macro(cx.psess(), sp, def_span, name, Some(&args), &body, rules);
387 cx.trace_macros_diag();
388 Err(guar)
389 }
390 }
391}
392
290393pub(super) enum CanRetry {
291394 Yes,
292395 /// We are not allowed to retry macro expansion as a fatal error has been emitted already.
......@@ -327,6 +430,7 @@ pub(super) fn try_match_macro<'matcher, T: Tracker<'matcher>>(
327430 // Try each arm's matchers.
328431 let mut tt_parser = TtParser::new(name);
329432 for (i, rule) in rules.iter().enumerate() {
433 let MacroRule::Func { lhs, .. } = rule else { continue };
330434 let _tracing_span = trace_span!("Matching arm", %i);
331435
332436 // Take a snapshot of the state of pre-expansion gating at this point.
......@@ -335,9 +439,9 @@ pub(super) fn try_match_macro<'matcher, T: Tracker<'matcher>>(
335439 // are not recorded. On the first `Success(..)`ful matcher, the spans are merged.
336440 let mut gated_spans_snapshot = mem::take(&mut *psess.gated_spans.spans.borrow_mut());
337441
338 let result = tt_parser.parse_tt(&mut Cow::Borrowed(&parser), &rule.lhs, track);
442 let result = tt_parser.parse_tt(&mut Cow::Borrowed(&parser), lhs, track);
339443
340 track.after_arm(&result);
444 track.after_arm(true, &result);
341445
342446 match result {
343447 Success(named_matches) => {
......@@ -372,6 +476,60 @@ pub(super) fn try_match_macro<'matcher, T: Tracker<'matcher>>(
372476 Err(CanRetry::Yes)
373477}
374478
479/// Try expanding the macro attribute. Returns the index of the successful arm and its
480/// named_matches if it was successful, and nothing if it failed. On failure, it's the caller's job
481/// to use `track` accordingly to record all errors correctly.
482#[instrument(level = "debug", skip(psess, attr_args, attr_body, rules, track), fields(tracking = %T::description()))]
483pub(super) fn try_match_macro_attr<'matcher, T: Tracker<'matcher>>(
484 psess: &ParseSess,
485 name: Ident,
486 attr_args: &TokenStream,
487 attr_body: &TokenStream,
488 rules: &'matcher [MacroRule],
489 track: &mut T,
490) -> Result<(usize, &'matcher MacroRule, NamedMatches), CanRetry> {
491 // This uses the same strategy as `try_match_macro`
492 let args_parser = parser_from_cx(psess, attr_args.clone(), T::recovery());
493 let body_parser = parser_from_cx(psess, attr_body.clone(), T::recovery());
494 let mut tt_parser = TtParser::new(name);
495 for (i, rule) in rules.iter().enumerate() {
496 let MacroRule::Attr { args, body, .. } = rule else { continue };
497
498 let mut gated_spans_snapshot = mem::take(&mut *psess.gated_spans.spans.borrow_mut());
499
500 let result = tt_parser.parse_tt(&mut Cow::Borrowed(&args_parser), args, track);
501 track.after_arm(false, &result);
502
503 let mut named_matches = match result {
504 Success(named_matches) => named_matches,
505 Failure(_) => {
506 mem::swap(&mut gated_spans_snapshot, &mut psess.gated_spans.spans.borrow_mut());
507 continue;
508 }
509 Error(_, _) => return Err(CanRetry::Yes),
510 ErrorReported(guar) => return Err(CanRetry::No(guar)),
511 };
512
513 let result = tt_parser.parse_tt(&mut Cow::Borrowed(&body_parser), body, track);
514 track.after_arm(true, &result);
515
516 match result {
517 Success(body_named_matches) => {
518 psess.gated_spans.merge(gated_spans_snapshot);
519 named_matches.extend(body_named_matches);
520 return Ok((i, rule, named_matches));
521 }
522 Failure(_) => {
523 mem::swap(&mut gated_spans_snapshot, &mut psess.gated_spans.spans.borrow_mut())
524 }
525 Error(_, _) => return Err(CanRetry::Yes),
526 ErrorReported(guar) => return Err(CanRetry::No(guar)),
527 }
528 }
529
530 Err(CanRetry::Yes)
531}
532
375533/// Converts a macro item into a syntax extension.
376534pub fn compile_declarative_macro(
377535 sess: &Session,
......@@ -382,13 +540,13 @@ pub fn compile_declarative_macro(
382540 span: Span,
383541 node_id: NodeId,
384542 edition: Edition,
385) -> (SyntaxExtension, usize) {
386 let mk_syn_ext = |expander| {
387 let kind = SyntaxExtensionKind::LegacyBang(expander);
543) -> (SyntaxExtension, Option<Arc<SyntaxExtension>>, usize) {
544 let mk_syn_ext = |kind| {
388545 let is_local = is_defined_in_current_crate(node_id);
389546 SyntaxExtension::new(sess, kind, span, Vec::new(), edition, ident.name, attrs, is_local)
390547 };
391 let dummy_syn_ext = |guar| (mk_syn_ext(Arc::new(DummyExpander(guar))), 0);
548 let mk_bang_ext = |expander| mk_syn_ext(SyntaxExtensionKind::LegacyBang(expander));
549 let dummy_syn_ext = |guar| (mk_bang_ext(Arc::new(DummyExpander(guar))), None, 0);
392550
393551 let macro_rules = macro_def.macro_rules;
394552 let exp_sep = if macro_rules { exp!(Semi) } else { exp!(Comma) };
......@@ -401,9 +559,30 @@ pub fn compile_declarative_macro(
401559 let mut guar = None;
402560 let mut check_emission = |ret: Result<(), ErrorGuaranteed>| guar = guar.or(ret.err());
403561
562 let mut has_attr_rules = false;
404563 let mut rules = Vec::new();
405564
406565 while p.token != token::Eof {
566 let args = if p.eat_keyword_noexpect(sym::attr) {
567 has_attr_rules = true;
568 if !features.macro_attr() {
569 feature_err(sess, sym::macro_attr, span, "`macro_rules!` attributes are unstable")
570 .emit();
571 }
572 if let Some(guar) = check_no_eof(sess, &p, "expected macro attr args") {
573 return dummy_syn_ext(guar);
574 }
575 let args = p.parse_token_tree();
576 check_args_parens(sess, &args);
577 let args = parse_one_tt(args, RulePart::Pattern, sess, node_id, features, edition);
578 check_emission(check_lhs(sess, node_id, &args));
579 if let Some(guar) = check_no_eof(sess, &p, "expected macro attr body") {
580 return dummy_syn_ext(guar);
581 }
582 Some(args)
583 } else {
584 None
585 };
407586 let lhs_tt = p.parse_token_tree();
408587 let lhs_tt = parse_one_tt(lhs_tt, RulePart::Pattern, sess, node_id, features, edition);
409588 check_emission(check_lhs(sess, node_id, &lhs_tt));
......@@ -416,7 +595,7 @@ pub fn compile_declarative_macro(
416595 let rhs_tt = p.parse_token_tree();
417596 let rhs_tt = parse_one_tt(rhs_tt, RulePart::Body, sess, node_id, features, edition);
418597 check_emission(check_rhs(sess, &rhs_tt));
419 check_emission(macro_check::check_meta_variables(&sess.psess, node_id, &lhs_tt, &rhs_tt));
598 check_emission(check_meta_variables(&sess.psess, node_id, args.as_ref(), &lhs_tt, &rhs_tt));
420599 let lhs_span = lhs_tt.span();
421600 // Convert the lhs into `MatcherLoc` form, which is better for doing the
422601 // actual matching.
......@@ -425,7 +604,17 @@ pub fn compile_declarative_macro(
425604 } else {
426605 return dummy_syn_ext(guar.unwrap());
427606 };
428 rules.push(MacroRule { lhs, lhs_span, rhs: rhs_tt });
607 if let Some(args) = args {
608 let args_span = args.span();
609 let mbe::TokenTree::Delimited(.., delimited) = args else {
610 return dummy_syn_ext(guar.unwrap());
611 };
612 let args = mbe::macro_parser::compute_locs(&delimited.tts);
613 let body_span = lhs_span;
614 rules.push(MacroRule::Attr { args, args_span, body: lhs, body_span, rhs: rhs_tt });
615 } else {
616 rules.push(MacroRule::Func { lhs, lhs_span, rhs: rhs_tt });
617 }
429618 if p.token == token::Eof {
430619 break;
431620 }
......@@ -451,9 +640,12 @@ pub fn compile_declarative_macro(
451640 // Return the number of rules for unused rule linting, if this is a local macro.
452641 let nrules = if is_defined_in_current_crate(node_id) { rules.len() } else { 0 };
453642
454 let expander =
455 Arc::new(MacroRulesMacroExpander { name: ident, span, node_id, transparency, rules });
456 (mk_syn_ext(expander), nrules)
643 let exp = Arc::new(MacroRulesMacroExpander { name: ident, span, node_id, transparency, rules });
644 let opt_attr_ext = has_attr_rules.then(|| {
645 let exp = Arc::clone(&exp);
646 Arc::new(mk_syn_ext(SyntaxExtensionKind::Attr(exp)))
647 });
648 (mk_bang_ext(exp), opt_attr_ext, nrules)
457649}
458650
459651fn check_no_eof(sess: &Session, p: &Parser<'_>, msg: &'static str) -> Option<ErrorGuaranteed> {
......@@ -469,6 +661,18 @@ fn check_no_eof(sess: &Session, p: &Parser<'_>, msg: &'static str) -> Option<Err
469661 None
470662}
471663
664fn check_args_parens(sess: &Session, args: &tokenstream::TokenTree) {
665 // This does not handle the non-delimited case; that gets handled separately by `check_lhs`.
666 if let tokenstream::TokenTree::Delimited(dspan, _, delim, _) = args
667 && *delim != Delimiter::Parenthesis
668 {
669 sess.dcx().emit_err(errors::MacroArgsBadDelim {
670 span: dspan.entire(),
671 sugg: errors::MacroArgsBadDelimSugg { open: dspan.open, close: dspan.close },
672 });
673 }
674}
675
472676fn check_lhs(sess: &Session, node_id: NodeId, lhs: &mbe::TokenTree) -> Result<(), ErrorGuaranteed> {
473677 let e1 = check_lhs_nt_follows(sess, node_id, lhs);
474678 let e2 = check_lhs_no_empty_seq(sess, slice::from_ref(lhs));
compiler/rustc_feature/src/unstable.rs+2
......@@ -554,6 +554,8 @@ declare_features! (
554554 (unstable, link_arg_attribute, "1.76.0", Some(99427)),
555555 /// Allows fused `loop`/`match` for direct intraprocedural jumps.
556556 (incomplete, loop_match, "1.90.0", Some(132306)),
557 /// Allow `macro_rules!` attribute rules
558 (unstable, macro_attr, "CURRENT_RUSTC_VERSION", Some(83527)),
557559 /// Give access to additional metadata about declarative macro meta-variables.
558560 (unstable, macro_metavar_expr, "1.61.0", Some(83527)),
559561 /// Provides a way to concatenate identifiers using metavariable expressions.
compiler/rustc_hir_analysis/src/check/intrinsic.rs+6-6
......@@ -652,16 +652,16 @@ pub(crate) fn check_intrinsic_type(
652652 sym::atomic_store => (1, 1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit),
653653
654654 sym::atomic_xchg
655 | sym::atomic_xadd
656 | sym::atomic_xsub
657 | sym::atomic_and
658 | sym::atomic_nand
659 | sym::atomic_or
660 | sym::atomic_xor
661655 | sym::atomic_max
662656 | sym::atomic_min
663657 | sym::atomic_umax
664658 | sym::atomic_umin => (1, 1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], param(0)),
659 sym::atomic_xadd
660 | sym::atomic_xsub
661 | sym::atomic_and
662 | sym::atomic_nand
663 | sym::atomic_or
664 | sym::atomic_xor => (2, 1, vec![Ty::new_mut_ptr(tcx, param(0)), param(1)], param(0)),
665665 sym::atomic_fence | sym::atomic_singlethreadfence => (0, 1, Vec::new(), tcx.types.unit),
666666
667667 other => {
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs+3-2
......@@ -1135,9 +1135,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
11351135 );
11361136 }
11371137 } else {
1138 let trait_ =
1139 tcx.short_string(bound.print_only_trait_path(), err.long_ty_path());
11381140 err.note(format!(
1139 "associated {assoc_kind_str} `{assoc_ident}` could derive from `{}`",
1140 bound.print_only_trait_path(),
1141 "associated {assoc_kind_str} `{assoc_ident}` could derive from `{trait_}`",
11411142 ));
11421143 }
11431144 }
compiler/rustc_hir_typeck/messages.ftl+2-2
......@@ -159,7 +159,7 @@ hir_typeck_lossy_provenance_ptr2int =
159159 .suggestion = use `.addr()` to obtain the address of a pointer
160160 .help = if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_provenance()` instead
161161
162hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty_str}`
162hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty}`
163163
164164hir_typeck_naked_asm_outside_naked_fn =
165165 the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`
......@@ -184,7 +184,7 @@ hir_typeck_never_type_fallback_flowing_into_unsafe_path = never type fallback af
184184hir_typeck_never_type_fallback_flowing_into_unsafe_union_field = never type fallback affects this union access
185185 .help = specify the type explicitly
186186
187hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method ->
187hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty}`{$trait_missing_method ->
188188 [true] {""}
189189 *[other] {" "}in the current scope
190190}
compiler/rustc_hir_typeck/src/errors.rs+4-4
......@@ -200,11 +200,11 @@ pub(crate) enum ExplicitDestructorCallSugg {
200200
201201#[derive(Diagnostic)]
202202#[diag(hir_typeck_missing_parentheses_in_range, code = E0689)]
203pub(crate) struct MissingParenthesesInRange {
203pub(crate) struct MissingParenthesesInRange<'tcx> {
204204 #[primary_span]
205205 #[label(hir_typeck_missing_parentheses_in_range)]
206206 pub span: Span,
207 pub ty_str: String,
207 pub ty: Ty<'tcx>,
208208 pub method_name: String,
209209 #[subdiagnostic]
210210 pub add_missing_parentheses: Option<AddMissingParenthesesInRange>,
......@@ -828,13 +828,13 @@ pub(crate) struct UnlabeledCfInWhileCondition<'a> {
828828
829829#[derive(Diagnostic)]
830830#[diag(hir_typeck_no_associated_item, code = E0599)]
831pub(crate) struct NoAssociatedItem {
831pub(crate) struct NoAssociatedItem<'tcx> {
832832 #[primary_span]
833833 pub span: Span,
834834 pub item_kind: &'static str,
835835 pub item_ident: Ident,
836836 pub ty_prefix: Cow<'static, str>,
837 pub ty_str: String,
837 pub ty: Ty<'tcx>,
838838 pub trait_missing_method: bool,
839839}
840840
compiler/rustc_hir_typeck/src/expr.rs+54-45
......@@ -2745,6 +2745,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27452745 let available_field_names = self.available_field_names(variant, expr, skip_fields);
27462746 if let Some(field_name) =
27472747 find_best_match_for_name(&available_field_names, field.ident.name, None)
2748 && !(field.ident.name.as_str().parse::<usize>().is_ok()
2749 && field_name.as_str().parse::<usize>().is_ok())
27482750 {
27492751 err.span_label(field.ident.span, "unknown field");
27502752 err.span_suggestion_verbose(
......@@ -3321,18 +3323,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33213323 } else {
33223324 (base_ty, "")
33233325 };
3324 for (found_fields, args) in
3326 for found_fields in
33253327 self.get_field_candidates_considering_privacy_for_diag(span, ty, mod_id, expr.hir_id)
33263328 {
3327 let field_names = found_fields.iter().map(|field| field.name).collect::<Vec<_>>();
3329 let field_names = found_fields.iter().map(|field| field.0.name).collect::<Vec<_>>();
33283330 let mut candidate_fields: Vec<_> = found_fields
33293331 .into_iter()
33303332 .filter_map(|candidate_field| {
33313333 self.check_for_nested_field_satisfying_condition_for_diag(
33323334 span,
3333 &|candidate_field, _| candidate_field.ident(self.tcx()) == field,
3335 &|candidate_field, _| candidate_field == field,
33343336 candidate_field,
3335 args,
33363337 vec![],
33373338 mod_id,
33383339 expr.hir_id,
......@@ -3361,6 +3362,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33613362 );
33623363 } else if let Some(field_name) =
33633364 find_best_match_for_name(&field_names, field.name, None)
3365 && !(field.name.as_str().parse::<usize>().is_ok()
3366 && field_name.as_str().parse::<usize>().is_ok())
33643367 {
33653368 err.span_suggestion_verbose(
33663369 field.span,
......@@ -3396,7 +3399,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33963399 base_ty: Ty<'tcx>,
33973400 mod_id: DefId,
33983401 hir_id: HirId,
3399 ) -> Vec<(Vec<&'tcx ty::FieldDef>, GenericArgsRef<'tcx>)> {
3402 ) -> Vec<Vec<(Ident, Ty<'tcx>)>> {
34003403 debug!("get_field_candidates(span: {:?}, base_t: {:?}", span, base_ty);
34013404
34023405 let mut autoderef = self.autoderef(span, base_ty).silence_errors();
......@@ -3422,7 +3425,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34223425 if fields.iter().all(|field| !field.vis.is_accessible_from(mod_id, tcx)) {
34233426 return None;
34243427 }
3425 return Some((
3428 return Some(
34263429 fields
34273430 .iter()
34283431 .filter(move |field| {
......@@ -3431,9 +3434,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34313434 })
34323435 // For compile-time reasons put a limit on number of fields we search
34333436 .take(100)
3437 .map(|field_def| {
3438 (
3439 field_def.ident(self.tcx).normalize_to_macros_2_0(),
3440 field_def.ty(self.tcx, args),
3441 )
3442 })
3443 .collect::<Vec<_>>(),
3444 );
3445 }
3446 ty::Tuple(types) => {
3447 return Some(
3448 types
3449 .iter()
3450 .enumerate()
3451 // For compile-time reasons put a limit on number of fields we search
3452 .take(100)
3453 .map(|(i, ty)| (Ident::from_str(&i.to_string()), ty))
34343454 .collect::<Vec<_>>(),
3435 *args,
3436 ));
3455 );
34373456 }
34383457 _ => None,
34393458 }
......@@ -3443,56 +3462,46 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34433462
34443463 /// This method is called after we have encountered a missing field error to recursively
34453464 /// search for the field
3465 #[instrument(skip(self, matches, mod_id, hir_id), level = "debug")]
34463466 pub(crate) fn check_for_nested_field_satisfying_condition_for_diag(
34473467 &self,
34483468 span: Span,
3449 matches: &impl Fn(&ty::FieldDef, Ty<'tcx>) -> bool,
3450 candidate_field: &ty::FieldDef,
3451 subst: GenericArgsRef<'tcx>,
3469 matches: &impl Fn(Ident, Ty<'tcx>) -> bool,
3470 (candidate_name, candidate_ty): (Ident, Ty<'tcx>),
34523471 mut field_path: Vec<Ident>,
34533472 mod_id: DefId,
34543473 hir_id: HirId,
34553474 ) -> Option<Vec<Ident>> {
3456 debug!(
3457 "check_for_nested_field_satisfying(span: {:?}, candidate_field: {:?}, field_path: {:?}",
3458 span, candidate_field, field_path
3459 );
3460
34613475 if field_path.len() > 3 {
34623476 // For compile-time reasons and to avoid infinite recursion we only check for fields
34633477 // up to a depth of three
3464 None
3465 } else {
3466 field_path.push(candidate_field.ident(self.tcx).normalize_to_macros_2_0());
3467 let field_ty = candidate_field.ty(self.tcx, subst);
3468 if matches(candidate_field, field_ty) {
3469 return Some(field_path);
3470 } else {
3471 for (nested_fields, subst) in self
3472 .get_field_candidates_considering_privacy_for_diag(
3473 span, field_ty, mod_id, hir_id,
3474 )
3475 {
3476 // recursively search fields of `candidate_field` if it's a ty::Adt
3477 for field in nested_fields {
3478 if let Some(field_path) = self
3479 .check_for_nested_field_satisfying_condition_for_diag(
3480 span,
3481 matches,
3482 field,
3483 subst,
3484 field_path.clone(),
3485 mod_id,
3486 hir_id,
3487 )
3488 {
3489 return Some(field_path);
3490 }
3491 }
3478 return None;
3479 }
3480 field_path.push(candidate_name);
3481 if matches(candidate_name, candidate_ty) {
3482 return Some(field_path);
3483 }
3484 for nested_fields in self.get_field_candidates_considering_privacy_for_diag(
3485 span,
3486 candidate_ty,
3487 mod_id,
3488 hir_id,
3489 ) {
3490 // recursively search fields of `candidate_field` if it's a ty::Adt
3491 for field in nested_fields {
3492 if let Some(field_path) = self.check_for_nested_field_satisfying_condition_for_diag(
3493 span,
3494 matches,
3495 field,
3496 field_path.clone(),
3497 mod_id,
3498 hir_id,
3499 ) {
3500 return Some(field_path);
34923501 }
34933502 }
3494 None
34953503 }
3504 None
34963505 }
34973506
34983507 fn check_expr_index(
compiler/rustc_hir_typeck/src/method/suggest.rs+62-77
......@@ -376,16 +376,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
376376 }
377377 }
378378
379 fn suggest_missing_writer(&self, rcvr_ty: Ty<'tcx>, rcvr_expr: &hir::Expr<'tcx>) -> Diag<'_> {
380 let mut file = None;
379 fn suggest_missing_writer(
380 &self,
381 rcvr_ty: Ty<'tcx>,
382 rcvr_expr: &hir::Expr<'tcx>,
383 mut long_ty_path: Option<PathBuf>,
384 ) -> Diag<'_> {
381385 let mut err = struct_span_code_err!(
382386 self.dcx(),
383387 rcvr_expr.span,
384388 E0599,
385389 "cannot write into `{}`",
386 self.tcx.short_string(rcvr_ty, &mut file),
390 self.tcx.short_string(rcvr_ty, &mut long_ty_path),
387391 );
388 *err.long_ty_path() = file;
392 *err.long_ty_path() = long_ty_path;
389393 err.span_note(
390394 rcvr_expr.span,
391395 "must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method",
......@@ -403,7 +407,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
403407 &self,
404408 self_source: SelfSource<'tcx>,
405409 method_name: Ident,
406 ty_str_reported: &str,
410 ty: Ty<'tcx>,
407411 err: &mut Diag<'_>,
408412 ) {
409413 #[derive(Debug)]
......@@ -478,7 +482,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
478482 }
479483
480484 // If the shadowed binding has an itializer expression,
481 // use the initializer expression'ty to try to find the method again.
485 // use the initializer expression's ty to try to find the method again.
482486 // For example like: `let mut x = Vec::new();`,
483487 // `Vec::new()` is the itializer expression.
484488 if let Some(self_ty) = self.fcx.node_ty_opt(binding.init_hir_id)
......@@ -566,17 +570,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
566570 let mut span = MultiSpan::from_span(sugg_let.span);
567571 span.push_span_label(sugg_let.span,
568572 format!("`{rcvr_name}` of type `{self_ty}` that has method `{method_name}` defined earlier here"));
573
574 let ty = self.tcx.short_string(ty, err.long_ty_path());
569575 span.push_span_label(
570576 self.tcx.hir_span(recv_id),
571 format!(
572 "earlier `{rcvr_name}` shadowed here with type `{ty_str_reported}`"
573 ),
577 format!("earlier `{rcvr_name}` shadowed here with type `{ty}`"),
574578 );
575579 err.span_note(
576580 span,
577581 format!(
578582 "there's an earlier shadowed binding `{rcvr_name}` of type `{self_ty}` \
579 that has method `{method_name}` available"
583 that has method `{method_name}` available"
580584 ),
581585 );
582586 }
......@@ -602,15 +606,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
602606 let tcx = self.tcx;
603607 let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty);
604608 let mut ty_file = None;
605 let (ty_str, short_ty_str) =
606 if trait_missing_method && let ty::Dynamic(predicates, _, _) = rcvr_ty.kind() {
607 (predicates.to_string(), with_forced_trimmed_paths!(predicates.to_string()))
608 } else {
609 (
610 tcx.short_string(rcvr_ty, &mut ty_file),
611 with_forced_trimmed_paths!(rcvr_ty.to_string()),
612 )
613 };
614609 let is_method = mode == Mode::MethodCall;
615610 let unsatisfied_predicates = &no_match_data.unsatisfied_predicates;
616611 let similar_candidate = no_match_data.similar_candidate;
......@@ -629,15 +624,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
629624
630625 // We could pass the file for long types into these two, but it isn't strictly necessary
631626 // given how targeted they are.
632 if let Err(guar) = self.report_failed_method_call_on_range_end(
633 tcx,
634 rcvr_ty,
635 source,
636 span,
637 item_ident,
638 &short_ty_str,
639 &mut ty_file,
640 ) {
627 if let Err(guar) =
628 self.report_failed_method_call_on_range_end(tcx, rcvr_ty, source, span, item_ident)
629 {
641630 return guar;
642631 }
643632 if let Err(guar) = self.report_failed_method_call_on_numerical_infer_var(
......@@ -647,44 +636,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
647636 span,
648637 item_kind,
649638 item_ident,
650 &short_ty_str,
651639 &mut ty_file,
652640 ) {
653641 return guar;
654642 }
655643 span = item_ident.span;
656644
657 // Don't show generic arguments when the method can't be found in any implementation (#81576).
658 let mut ty_str_reported = ty_str.clone();
659 if let ty::Adt(_, generics) = rcvr_ty.kind() {
660 if generics.len() > 0 {
661 let mut autoderef = self.autoderef(span, rcvr_ty).silence_errors();
662 let candidate_found = autoderef.any(|(ty, _)| {
663 if let ty::Adt(adt_def, _) = ty.kind() {
664 self.tcx
665 .inherent_impls(adt_def.did())
666 .into_iter()
667 .any(|def_id| self.associated_value(*def_id, item_ident).is_some())
668 } else {
669 false
670 }
671 });
672 let has_deref = autoderef.step_count() > 0;
673 if !candidate_found && !has_deref && unsatisfied_predicates.is_empty() {
674 if let Some((path_string, _)) = ty_str.split_once('<') {
675 ty_str_reported = path_string.to_string();
676 }
677 }
678 }
679 }
680
681645 let is_write = sugg_span.ctxt().outer_expn_data().macro_def_id.is_some_and(|def_id| {
682646 tcx.is_diagnostic_item(sym::write_macro, def_id)
683647 || tcx.is_diagnostic_item(sym::writeln_macro, def_id)
684648 }) && item_ident.name == sym::write_fmt;
685649 let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source {
686 self.suggest_missing_writer(rcvr_ty, rcvr_expr)
650 self.suggest_missing_writer(rcvr_ty, rcvr_expr, ty_file)
687651 } else {
652 // Don't show expanded generic arguments when the method can't be found in any
653 // implementation (#81576).
654 let mut ty = rcvr_ty;
655 if let ty::Adt(def, generics) = rcvr_ty.kind() {
656 if generics.len() > 0 {
657 let mut autoderef = self.autoderef(span, rcvr_ty).silence_errors();
658 let candidate_found = autoderef.any(|(ty, _)| {
659 if let ty::Adt(adt_def, _) = ty.kind() {
660 self.tcx
661 .inherent_impls(adt_def.did())
662 .into_iter()
663 .any(|def_id| self.associated_value(*def_id, item_ident).is_some())
664 } else {
665 false
666 }
667 });
668 let has_deref = autoderef.step_count() > 0;
669 if !candidate_found && !has_deref && unsatisfied_predicates.is_empty() {
670 ty = self.tcx.at(span).type_of(def.did()).instantiate_identity();
671 }
672 }
673 }
674
688675 let mut err = self.dcx().create_err(NoAssociatedItem {
689676 span,
690677 item_kind,
......@@ -695,16 +682,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
695682 } else {
696683 rcvr_ty.prefix_string(self.tcx)
697684 },
698 ty_str: ty_str_reported.clone(),
685 ty,
699686 trait_missing_method,
700687 });
701688
702689 if is_method {
703690 self.suggest_use_shadowed_binding_with_method(
704 source,
705 item_ident,
706 &ty_str_reported,
707 &mut err,
691 source, item_ident, rcvr_ty, &mut err,
708692 );
709693 }
710694
......@@ -734,6 +718,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
734718
735719 err
736720 };
721
737722 if tcx.sess.source_map().is_multiline(sugg_span) {
738723 err.span_label(sugg_span.with_hi(span.lo()), "");
739724 }
......@@ -750,6 +735,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
750735 }
751736
752737 if tcx.ty_is_opaque_future(rcvr_ty) && item_ident.name == sym::poll {
738 let ty_str = self.tcx.short_string(rcvr_ty, err.long_ty_path());
753739 err.help(format!(
754740 "method `poll` found on `Pin<&mut {ty_str}>`, \
755741 see documentation for `std::pin::Pin`"
......@@ -1339,7 +1325,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13391325 }
13401326 let OnUnimplementedNote { message, label, notes, .. } = self
13411327 .err_ctxt()
1342 .on_unimplemented_note(trait_ref, &obligation, &mut ty_file);
1328 .on_unimplemented_note(trait_ref, &obligation, err.long_ty_path());
13431329 (message, label, notes)
13441330 })
13451331 .unwrap()
......@@ -1347,6 +1333,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13471333 (None, None, Vec::new())
13481334 };
13491335 let primary_message = primary_message.unwrap_or_else(|| {
1336 let ty_str = self.tcx.short_string(rcvr_ty, err.long_ty_path());
13501337 format!(
13511338 "the {item_kind} `{item_ident}` exists for {actual_prefix} `{ty_str}`, \
13521339 but its trait bounds were not satisfied"
......@@ -1409,6 +1396,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14091396 let mut find_candidate_for_method = false;
14101397
14111398 let mut label_span_not_found = |err: &mut Diag<'_>| {
1399 let ty_str = self.tcx.short_string(rcvr_ty, err.long_ty_path());
14121400 if unsatisfied_predicates.is_empty() {
14131401 err.span_label(span, format!("{item_kind} not found in `{ty_str}`"));
14141402 let is_string_or_ref_str = match rcvr_ty.kind() {
......@@ -2520,8 +2508,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25202508 source: SelfSource<'tcx>,
25212509 span: Span,
25222510 item_name: Ident,
2523 ty_str: &str,
2524 long_ty_path: &mut Option<PathBuf>,
25252511 ) -> Result<(), ErrorGuaranteed> {
25262512 if let SelfSource::MethodCall(expr) = source {
25272513 for (_, parent) in tcx.hir_parent_iter(expr.hir_id).take(5) {
......@@ -2583,18 +2569,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25832569 );
25842570 if pick.is_ok() {
25852571 let range_span = parent_expr.span.with_hi(expr.span.hi());
2586 let mut err = self.dcx().create_err(errors::MissingParenthesesInRange {
2572 return Err(self.dcx().emit_err(errors::MissingParenthesesInRange {
25872573 span,
2588 ty_str: ty_str.to_string(),
2574 ty: actual,
25892575 method_name: item_name.as_str().to_string(),
25902576 add_missing_parentheses: Some(errors::AddMissingParenthesesInRange {
25912577 func_name: item_name.name.as_str().to_string(),
25922578 left: range_span.shrink_to_lo(),
25932579 right: range_span.shrink_to_hi(),
25942580 }),
2595 });
2596 *err.long_ty_path() = long_ty_path.take();
2597 return Err(err.emit());
2581 }));
25982582 }
25992583 }
26002584 }
......@@ -2610,7 +2594,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26102594 span: Span,
26112595 item_kind: &str,
26122596 item_name: Ident,
2613 ty_str: &str,
26142597 long_ty_path: &mut Option<PathBuf>,
26152598 ) -> Result<(), ErrorGuaranteed> {
26162599 let found_candidate = all_traits(self.tcx)
......@@ -2643,14 +2626,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26432626 && !actual.has_concrete_skeleton()
26442627 && let SelfSource::MethodCall(expr) = source
26452628 {
2629 let ty_str = self.tcx.short_string(actual, long_ty_path);
26462630 let mut err = struct_span_code_err!(
26472631 self.dcx(),
26482632 span,
26492633 E0689,
2650 "can't call {} `{}` on ambiguous numeric type `{}`",
2651 item_kind,
2652 item_name,
2653 ty_str
2634 "can't call {item_kind} `{item_name}` on ambiguous numeric type `{ty_str}`"
26542635 );
26552636 *err.long_ty_path() = long_ty_path.take();
26562637 let concrete_type = if actual.is_integral() { "i32" } else { "f32" };
......@@ -2792,7 +2773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27922773 ) {
27932774 if let SelfSource::MethodCall(expr) = source {
27942775 let mod_id = self.tcx.parent_module(expr.hir_id).to_def_id();
2795 for (fields, args) in self.get_field_candidates_considering_privacy_for_diag(
2776 for fields in self.get_field_candidates_considering_privacy_for_diag(
27962777 span,
27972778 actual,
27982779 mod_id,
......@@ -2831,7 +2812,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28312812 })
28322813 },
28332814 candidate_field,
2834 args,
28352815 vec![],
28362816 mod_id,
28372817 expr.hir_id,
......@@ -3671,7 +3651,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
36713651 )
36723652 {
36733653 debug!("try_alt_rcvr: pick candidate {:?}", pick);
3674 let did = Some(pick.item.container_id(self.tcx));
3654 let did = pick.item.trait_container(self.tcx);
36753655 // We don't want to suggest a container type when the missing
36763656 // method is `.clone()` or `.deref()` otherwise we'd suggest
36773657 // `Arc::new(foo).clone()`, which is far from what the user wants.
......@@ -3720,8 +3700,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37203700 && !alt_rcvr_sugg
37213701 // `T: !Unpin`
37223702 && !unpin
3723 // The method isn't `as_ref`, as it would provide a wrong suggestion for `Pin`.
3724 && sym::as_ref != item_name.name
37253703 // Either `Pin::as_ref` or `Pin::as_mut`.
37263704 && let Some(pin_call) = pin_call
37273705 // Search for `item_name` as a method accessible on `Pin<T>`.
......@@ -3735,6 +3713,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37353713 // We skip some common traits that we don't want to consider because autoderefs
37363714 // would take care of them.
37373715 && !skippable.contains(&Some(pick.item.container_id(self.tcx)))
3716 // Do not suggest pinning when the method is directly on `Pin`.
3717 && pick.item.impl_container(self.tcx).map_or(true, |did| {
3718 match self.tcx.type_of(did).skip_binder().kind() {
3719 ty::Adt(def, _) => Some(def.did()) != self.tcx.lang_items().pin_type(),
3720 _ => true,
3721 }
3722 })
37383723 // We don't want to go through derefs.
37393724 && pick.autoderefs == 0
37403725 // Check that the method of the same name that was found on the new `Pin<T>`
compiler/rustc_metadata/src/native_libs.rs+1-1
......@@ -83,7 +83,7 @@ pub fn walk_native_lib_search_dirs<R>(
8383 // Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks
8484 // we must have the support library stubs in the library search path (#121430).
8585 if let Some(sdk_root) = apple_sdk_root
86 && sess.target.llvm_target.contains("macabi")
86 && sess.target.env == "macabi"
8787 {
8888 f(&sdk_root.join("System/iOSSupport/usr/lib"), false)?;
8989 f(&sdk_root.join("System/iOSSupport/System/Library/Frameworks"), true)?;
compiler/rustc_middle/src/ty/generic_args.rs+12-5
......@@ -527,21 +527,28 @@ impl<'tcx> GenericArgs<'tcx> {
527527 #[inline]
528528 #[track_caller]
529529 pub fn type_at(&self, i: usize) -> Ty<'tcx> {
530 self[i].as_type().unwrap_or_else(|| bug!("expected type for param #{} in {:?}", i, self))
530 self[i].as_type().unwrap_or_else(
531 #[track_caller]
532 || bug!("expected type for param #{} in {:?}", i, self),
533 )
531534 }
532535
533536 #[inline]
534537 #[track_caller]
535538 pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
536 self[i]
537 .as_region()
538 .unwrap_or_else(|| bug!("expected region for param #{} in {:?}", i, self))
539 self[i].as_region().unwrap_or_else(
540 #[track_caller]
541 || bug!("expected region for param #{} in {:?}", i, self),
542 )
539543 }
540544
541545 #[inline]
542546 #[track_caller]
543547 pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
544 self[i].as_const().unwrap_or_else(|| bug!("expected const for param #{} in {:?}", i, self))
548 self[i].as_const().unwrap_or_else(
549 #[track_caller]
550 || bug!("expected const for param #{} in {:?}", i, self),
551 )
545552 }
546553
547554 #[inline]
compiler/rustc_middle/src/ty/print/pretty.rs+1-1
......@@ -2987,7 +2987,7 @@ impl<'tcx> ty::Binder<'tcx, ty::TraitRef<'tcx>> {
29872987 }
29882988}
29892989
2990#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)]
2990#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift, Hash)]
29912991pub struct TraitPredPrintModifiersAndPath<'tcx>(ty::TraitPredicate<'tcx>);
29922992
29932993impl<'tcx> fmt::Debug for TraitPredPrintModifiersAndPath<'tcx> {
compiler/rustc_pattern_analysis/src/constructor.rs+5-5
......@@ -1130,16 +1130,16 @@ impl<Cx: PatCx> ConstructorSet<Cx> {
11301130 seen_false = true;
11311131 }
11321132 }
1133 if seen_false {
1134 present.push(Bool(false));
1135 } else {
1136 missing.push(Bool(false));
1137 }
11381133 if seen_true {
11391134 present.push(Bool(true));
11401135 } else {
11411136 missing.push(Bool(true));
11421137 }
1138 if seen_false {
1139 present.push(Bool(false));
1140 } else {
1141 missing.push(Bool(false));
1142 }
11431143 }
11441144 ConstructorSet::Integers { range_1, range_2 } => {
11451145 let seen_ranges: Vec<_> =
compiler/rustc_pattern_analysis/tests/exhaustiveness.rs+3
......@@ -176,6 +176,9 @@ fn test_witnesses() {
176176 ),
177177 vec!["Enum::Variant1(_)", "Enum::Variant2(_)", "_"],
178178 );
179
180 // Assert we put `true` before `false`.
181 assert_witnesses(AllOfThem, Ty::Bool, Vec::new(), vec!["true", "false"]);
179182}
180183
181184#[test]
compiler/rustc_resolve/messages.ftl+1-1
......@@ -243,7 +243,7 @@ resolve_lowercase_self =
243243 .suggestion = try using `Self`
244244
245245resolve_macro_cannot_use_as_attr =
246 `{$ident}` exists, but a declarative macro cannot be used as an attribute macro
246 `{$ident}` exists, but has no `attr` rules
247247
248248resolve_macro_cannot_use_as_derive =
249249 `{$ident}` exists, but a declarative macro cannot be used as a derive macro
compiler/rustc_resolve/src/ident.rs+16-4
......@@ -631,9 +631,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
631631 };
632632
633633 match result {
634 Ok((binding, flags))
635 if sub_namespace_match(binding.macro_kind(), macro_kind) =>
636 {
634 Ok((binding, flags)) => {
635 let binding_macro_kind = binding.macro_kind();
636 // If we're looking for an attribute, that might be supported by a
637 // `macro_rules!` macro.
638 // FIXME: Replace this with tracking multiple macro kinds for one Def.
639 if !(sub_namespace_match(binding_macro_kind, macro_kind)
640 || (binding_macro_kind == Some(MacroKind::Bang)
641 && macro_kind == Some(MacroKind::Attr)
642 && this
643 .get_macro(binding.res())
644 .is_some_and(|macro_data| macro_data.attr_ext.is_some())))
645 {
646 return None;
647 }
648
637649 if finalize.is_none() || matches!(scope_set, ScopeSet::Late(..)) {
638650 return Some(Ok(binding));
639651 }
......@@ -710,7 +722,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
710722 innermost_result = Some((binding, flags));
711723 }
712724 }
713 Ok(..) | Err(Determinacy::Determined) => {}
725 Err(Determinacy::Determined) => {}
714726 Err(Determinacy::Undetermined) => determinacy = Determinacy::Undetermined,
715727 }
716728
compiler/rustc_resolve/src/lib.rs+2-1
......@@ -1029,13 +1029,14 @@ struct DeriveData {
10291029
10301030struct MacroData {
10311031 ext: Arc<SyntaxExtension>,
1032 attr_ext: Option<Arc<SyntaxExtension>>,
10321033 nrules: usize,
10331034 macro_rules: bool,
10341035}
10351036
10361037impl MacroData {
10371038 fn new(ext: Arc<SyntaxExtension>) -> MacroData {
1038 MacroData { ext, nrules: 0, macro_rules: false }
1039 MacroData { ext, attr_ext: None, nrules: 0, macro_rules: false }
10391040 }
10401041}
10411042
compiler/rustc_resolve/src/macros.rs+7-3
......@@ -842,7 +842,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
842842 }
843843 _ => None,
844844 },
845 None => self.get_macro(res).map(|macro_data| Arc::clone(&macro_data.ext)),
845 None => self.get_macro(res).map(|macro_data| match kind {
846 Some(MacroKind::Attr) if let Some(ref ext) = macro_data.attr_ext => Arc::clone(ext),
847 _ => Arc::clone(&macro_data.ext),
848 }),
846849 };
847850 Ok((ext, res))
848851 }
......@@ -1178,7 +1181,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11781181 node_id: NodeId,
11791182 edition: Edition,
11801183 ) -> MacroData {
1181 let (mut ext, mut nrules) = compile_declarative_macro(
1184 let (mut ext, mut attr_ext, mut nrules) = compile_declarative_macro(
11821185 self.tcx.sess,
11831186 self.tcx.features(),
11841187 macro_def,
......@@ -1195,13 +1198,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11951198 // The macro is a built-in, replace its expander function
11961199 // while still taking everything else from the source code.
11971200 ext.kind = builtin_ext_kind.clone();
1201 attr_ext = None;
11981202 nrules = 0;
11991203 } else {
12001204 self.dcx().emit_err(errors::CannotFindBuiltinMacroWithName { span, ident });
12011205 }
12021206 }
12031207
1204 MacroData { ext: Arc::new(ext), nrules, macro_rules: macro_def.macro_rules }
1208 MacroData { ext: Arc::new(ext), attr_ext, nrules, macro_rules: macro_def.macro_rules }
12051209 }
12061210
12071211 fn path_accessible(
compiler/rustc_span/src/symbol.rs+1
......@@ -1311,6 +1311,7 @@ symbols! {
13111311 lt,
13121312 m68k_target_feature,
13131313 macro_at_most_once_rep,
1314 macro_attr,
13141315 macro_attributes_in_derive_output,
13151316 macro_concat,
13161317 macro_escape,
compiler/rustc_target/src/spec/base/apple/mod.rs+25-18
......@@ -51,14 +51,14 @@ impl Arch {
5151 })
5252 }
5353
54 fn target_cpu(self, abi: TargetAbi) -> &'static str {
54 fn target_cpu(self, env: TargetEnv) -> &'static str {
5555 match self {
5656 Armv7k => "cortex-a8",
5757 Armv7s => "swift", // iOS 10 is only supported on iPhone 5 or higher.
58 Arm64 => match abi {
59 TargetAbi::Normal => "apple-a7",
60 TargetAbi::Simulator => "apple-a12",
61 TargetAbi::MacCatalyst => "apple-a12",
58 Arm64 => match env {
59 TargetEnv::Normal => "apple-a7",
60 TargetEnv::Simulator => "apple-a12",
61 TargetEnv::MacCatalyst => "apple-a12",
6262 },
6363 Arm64e => "apple-a12",
6464 Arm64_32 => "apple-s4",
......@@ -83,14 +83,14 @@ impl Arch {
8383}
8484
8585#[derive(Copy, Clone, PartialEq)]
86pub(crate) enum TargetAbi {
86pub(crate) enum TargetEnv {
8787 Normal,
8888 Simulator,
8989 MacCatalyst,
9090}
9191
92impl TargetAbi {
93 fn target_abi(self) -> &'static str {
92impl TargetEnv {
93 fn target_env(self) -> &'static str {
9494 match self {
9595 Self::Normal => "",
9696 Self::MacCatalyst => "macabi",
......@@ -104,13 +104,20 @@ impl TargetAbi {
104104pub(crate) fn base(
105105 os: &'static str,
106106 arch: Arch,
107 abi: TargetAbi,
107 env: TargetEnv,
108108) -> (TargetOptions, StaticCow<str>, StaticCow<str>) {
109109 let mut opts = TargetOptions {
110 abi: abi.target_abi().into(),
111110 llvm_floatabi: Some(FloatAbi::Hard),
112111 os: os.into(),
113 cpu: arch.target_cpu(abi).into(),
112 env: env.target_env().into(),
113 // NOTE: We originally set `cfg(target_abi = "macabi")` / `cfg(target_abi = "sim")`,
114 // before it was discovered that those are actually environments:
115 // https://github.com/rust-lang/rust/issues/133331
116 //
117 // But let's continue setting them for backwards compatibility.
118 // FIXME(madsmtm): Warn about using these in the future.
119 abi: env.target_env().into(),
120 cpu: arch.target_cpu(env).into(),
114121 link_env_remove: link_env_remove(os),
115122 vendor: "apple".into(),
116123 linker_flavor: LinkerFlavor::Darwin(Cc::Yes, Lld::No),
......@@ -168,14 +175,14 @@ pub(crate) fn base(
168175 // All Apple x86-32 targets have SSE2.
169176 opts.rustc_abi = Some(RustcAbi::X86Sse2);
170177 }
171 (opts, unversioned_llvm_target(os, arch, abi), arch.target_arch())
178 (opts, unversioned_llvm_target(os, arch, env), arch.target_arch())
172179}
173180
174181/// Generate part of the LLVM target triple.
175182///
176183/// See `rustc_codegen_ssa::back::versioned_llvm_target` for the full triple passed to LLVM and
177184/// Clang.
178fn unversioned_llvm_target(os: &str, arch: Arch, abi: TargetAbi) -> StaticCow<str> {
185fn unversioned_llvm_target(os: &str, arch: Arch, env: TargetEnv) -> StaticCow<str> {
179186 let arch = arch.target_name();
180187 // Convert to the "canonical" OS name used by LLVM:
181188 // https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L236-L282
......@@ -187,10 +194,10 @@ fn unversioned_llvm_target(os: &str, arch: Arch, abi: TargetAbi) -> StaticCow<st
187194 "visionos" => "xros",
188195 _ => unreachable!("tried to get LLVM target OS for non-Apple platform"),
189196 };
190 let environment = match abi {
191 TargetAbi::Normal => "",
192 TargetAbi::MacCatalyst => "-macabi",
193 TargetAbi::Simulator => "-simulator",
197 let environment = match env {
198 TargetEnv::Normal => "",
199 TargetEnv::MacCatalyst => "-macabi",
200 TargetEnv::Simulator => "-simulator",
194201 };
195202 format!("{arch}-apple-{os}{environment}").into()
196203}
......@@ -309,7 +316,7 @@ impl OSVersion {
309316 /// This matches what LLVM does, see in part:
310317 /// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
311318 pub fn minimum_deployment_target(target: &Target) -> Self {
312 let (major, minor, patch) = match (&*target.os, &*target.arch, &*target.abi) {
319 let (major, minor, patch) = match (&*target.os, &*target.arch, &*target.env) {
313320 ("macos", "aarch64", _) => (11, 0, 0),
314321 ("ios", "aarch64", "macabi") => (14, 0, 0),
315322 ("ios", "aarch64", "sim") => (14, 0, 0),
compiler/rustc_target/src/spec/base/apple/tests.rs+4-2
......@@ -6,7 +6,7 @@ use crate::spec::targets::{
66};
77
88#[test]
9fn simulator_targets_set_abi() {
9fn simulator_targets_set_env() {
1010 let all_sim_targets = [
1111 x86_64_apple_ios::target(),
1212 x86_64_apple_tvos::target(),
......@@ -18,7 +18,9 @@ fn simulator_targets_set_abi() {
1818 ];
1919
2020 for target in &all_sim_targets {
21 assert_eq!(target.abi, "sim")
21 assert_eq!(target.env, "sim");
22 // Ensure backwards compat
23 assert_eq!(target.abi, "sim");
2224 }
2325}
2426
compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("macos", Arch::Arm64, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("macos", Arch::Arm64, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetAbi::MacCatalyst);
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetEnv::MacCatalyst);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetAbi::Simulator);
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64, TargetEnv::Simulator);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("tvos", Arch::Arm64, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("tvos", Arch::Arm64, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("tvos", Arch::Arm64, TargetAbi::Simulator);
5 let (opts, llvm_target, arch) = base("tvos", Arch::Arm64, TargetEnv::Simulator);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("visionos", Arch::Arm64, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("visionos", Arch::Arm64, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("visionos", Arch::Arm64, TargetAbi::Simulator);
5 let (opts, llvm_target, arch) = base("visionos", Arch::Arm64, TargetEnv::Simulator);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_watchos.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("watchos", Arch::Arm64, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("watchos", Arch::Arm64, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("watchos", Arch::Arm64, TargetAbi::Simulator);
5 let (opts, llvm_target, arch) = base("watchos", Arch::Arm64, TargetEnv::Simulator);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("watchos", Arch::Arm64_32, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("watchos", Arch::Arm64_32, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/arm64e_apple_darwin.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("macos", Arch::Arm64e, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("macos", Arch::Arm64e, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/arm64e_apple_ios.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64e, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("ios", Arch::Arm64e, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("tvos", Arch::Arm64e, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("tvos", Arch::Arm64e, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/armv7k_apple_watchos.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("watchos", Arch::Armv7k, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("watchos", Arch::Armv7k, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/armv7s_apple_ios.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("ios", Arch::Armv7s, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("ios", Arch::Armv7s, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/i386_apple_ios.rs+2-2
......@@ -1,10 +1,10 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
55 // i386-apple-ios is a simulator target, even though it isn't declared
66 // that way in the target name like the other ones...
7 let (opts, llvm_target, arch) = base("ios", Arch::I386, TargetAbi::Simulator);
7 let (opts, llvm_target, arch) = base("ios", Arch::I386, TargetEnv::Simulator);
88 Target {
99 llvm_target,
1010 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("macos", Arch::I686, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("macos", Arch::I686, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("macos", Arch::X86_64, TargetAbi::Normal);
5 let (opts, llvm_target, arch) = base("macos", Arch::X86_64, TargetEnv::Normal);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs+2-2
......@@ -1,10 +1,10 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
55 // x86_64-apple-ios is a simulator target, even though it isn't declared
66 // that way in the target name like the other ones...
7 let (opts, llvm_target, arch) = base("ios", Arch::X86_64, TargetAbi::Simulator);
7 let (opts, llvm_target, arch) = base("ios", Arch::X86_64, TargetEnv::Simulator);
88 Target {
99 llvm_target,
1010 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/x86_64_apple_ios_macabi.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("ios", Arch::X86_64, TargetAbi::MacCatalyst);
5 let (opts, llvm_target, arch) = base("ios", Arch::X86_64, TargetEnv::MacCatalyst);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/x86_64_apple_tvos.rs+2-2
......@@ -1,10 +1,10 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
55 // x86_64-apple-tvos is a simulator target, even though it isn't declared
66 // that way in the target name like the other ones...
7 let (opts, llvm_target, arch) = base("tvos", Arch::X86_64, TargetAbi::Simulator);
7 let (opts, llvm_target, arch) = base("tvos", Arch::X86_64, TargetEnv::Simulator);
88 Target {
99 llvm_target,
1010 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/x86_64_apple_watchos_sim.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (opts, llvm_target, arch) = base("watchos", Arch::X86_64, TargetAbi::Simulator);
5 let (opts, llvm_target, arch) = base("watchos", Arch::X86_64, TargetEnv::Simulator);
66 Target {
77 llvm_target,
88 metadata: TargetMetadata {
compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::spec::base::apple::{Arch, TargetAbi, base};
1use crate::spec::base::apple::{Arch, TargetEnv, base};
22use crate::spec::{SanitizerSet, Target, TargetMetadata, TargetOptions};
33
44pub(crate) fn target() -> Target {
5 let (mut opts, llvm_target, arch) = base("macos", Arch::X86_64h, TargetAbi::Normal);
5 let (mut opts, llvm_target, arch) = base("macos", Arch::X86_64h, TargetEnv::Normal);
66 opts.max_atomic_width = Some(128);
77 opts.supported_sanitizers =
88 SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD;
compiler/rustc_trait_selection/messages.ftl-2
......@@ -171,8 +171,6 @@ trait_selection_fps_remove_ref = consider removing the reference
171171trait_selection_fps_use_ref = consider using a reference
172172trait_selection_fulfill_req_lifetime = the type `{$ty}` does not fulfill the required lifetime
173173
174trait_selection_full_type_written = the full type name has been written to '{$path}'
175
176174trait_selection_ignored_diagnostic_option = `{$option_name}` is ignored due to previous definition of `{$option_name}`
177175 .other_label = `{$option_name}` is first declared here
178176 .label = `{$option_name}` is already declared here
compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs+8-7
......@@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19301930 &self,
19311931 trace: &TypeTrace<'tcx>,
19321932 terr: TypeError<'tcx>,
1933 path: &mut Option<PathBuf>,
1933 long_ty_path: &mut Option<PathBuf>,
19341934 ) -> Vec<TypeErrorAdditionalDiags> {
19351935 let mut suggestions = Vec::new();
19361936 let span = trace.cause.span;
......@@ -2009,7 +2009,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
20092009 })
20102010 | ObligationCauseCode::BlockTailExpression(.., source)) = code
20112011 && let hir::MatchSource::TryDesugar(_) = source
2012 && let Some((expected_ty, found_ty)) = self.values_str(trace.values, &trace.cause, path)
2012 && let Some((expected_ty, found_ty)) =
2013 self.values_str(trace.values, &trace.cause, long_ty_path)
20132014 {
20142015 suggestions.push(TypeErrorAdditionalDiags::TryCannotConvert {
20152016 found: found_ty.content(),
......@@ -2139,11 +2140,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21392140 &self,
21402141 values: ValuePairs<'tcx>,
21412142 cause: &ObligationCause<'tcx>,
2142 file: &mut Option<PathBuf>,
2143 long_ty_path: &mut Option<PathBuf>,
21432144 ) -> Option<(DiagStyledString, DiagStyledString)> {
21442145 match values {
21452146 ValuePairs::Regions(exp_found) => self.expected_found_str(exp_found),
2146 ValuePairs::Terms(exp_found) => self.expected_found_str_term(exp_found, file),
2147 ValuePairs::Terms(exp_found) => self.expected_found_str_term(exp_found, long_ty_path),
21472148 ValuePairs::Aliases(exp_found) => self.expected_found_str(exp_found),
21482149 ValuePairs::ExistentialTraitRef(exp_found) => self.expected_found_str(exp_found),
21492150 ValuePairs::ExistentialProjection(exp_found) => self.expected_found_str(exp_found),
......@@ -2183,7 +2184,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21832184 fn expected_found_str_term(
21842185 &self,
21852186 exp_found: ty::error::ExpectedFound<ty::Term<'tcx>>,
2186 path: &mut Option<PathBuf>,
2187 long_ty_path: &mut Option<PathBuf>,
21872188 ) -> Option<(DiagStyledString, DiagStyledString)> {
21882189 let exp_found = self.resolve_vars_if_possible(exp_found);
21892190 if exp_found.references_error() {
......@@ -2200,11 +2201,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
22002201 let exp_s = exp.content();
22012202 let fnd_s = fnd.content();
22022203 if exp_s.len() > len {
2203 let exp_s = self.tcx.short_string(expected, path);
2204 let exp_s = self.tcx.short_string(expected, long_ty_path);
22042205 exp = DiagStyledString::highlighted(exp_s);
22052206 }
22062207 if fnd_s.len() > len {
2207 let fnd_s = self.tcx.short_string(found, path);
2208 let fnd_s = self.tcx.short_string(found, long_ty_path);
22082209 fnd = DiagStyledString::highlighted(fnd_s);
22092210 }
22102211 (exp, fnd)
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs+12-20
......@@ -436,8 +436,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
436436 infer_subdiags,
437437 multi_suggestions,
438438 bad_label,
439 was_written: false,
440 path: Default::default(),
441439 }),
442440 TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
443441 span,
......@@ -447,8 +445,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
447445 infer_subdiags,
448446 multi_suggestions,
449447 bad_label,
450 was_written: false,
451 path: Default::default(),
452448 }),
453449 TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn {
454450 span,
......@@ -458,8 +454,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
458454 infer_subdiags,
459455 multi_suggestions,
460456 bad_label,
461 was_written: false,
462 path: Default::default(),
463457 }),
464458 }
465459 }
......@@ -496,7 +490,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
496490 return self.bad_inference_failure_err(failure_span, arg_data, error_code);
497491 };
498492
499 let (source_kind, name, path) = kind.ty_localized_msg(self);
493 let (source_kind, name, long_ty_path) = kind.ty_localized_msg(self);
500494 let failure_span = if should_label_span && !failure_span.overlaps(span) {
501495 Some(failure_span)
502496 } else {
......@@ -628,7 +622,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
628622 }
629623 }
630624 }
631 match error_code {
625 let mut err = match error_code {
632626 TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired {
633627 span,
634628 source_kind,
......@@ -637,8 +631,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
637631 infer_subdiags,
638632 multi_suggestions,
639633 bad_label: None,
640 was_written: path.is_some(),
641 path: path.unwrap_or_default(),
642634 }),
643635 TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
644636 span,
......@@ -648,8 +640,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
648640 infer_subdiags,
649641 multi_suggestions,
650642 bad_label: None,
651 was_written: path.is_some(),
652 path: path.unwrap_or_default(),
653643 }),
654644 TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn {
655645 span,
......@@ -659,10 +649,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
659649 infer_subdiags,
660650 multi_suggestions,
661651 bad_label: None,
662 was_written: path.is_some(),
663 path: path.unwrap_or_default(),
664652 }),
665 }
653 };
654 *err.long_ty_path() = long_ty_path;
655 err
666656 }
667657}
668658
......@@ -726,22 +716,24 @@ impl<'tcx> InferSource<'tcx> {
726716
727717impl<'tcx> InferSourceKind<'tcx> {
728718 fn ty_localized_msg(&self, infcx: &InferCtxt<'tcx>) -> (&'static str, String, Option<PathBuf>) {
729 let mut path = None;
719 let mut long_ty_path = None;
730720 match *self {
731721 InferSourceKind::LetBinding { ty, .. }
732722 | InferSourceKind::ClosureArg { ty, .. }
733723 | InferSourceKind::ClosureReturn { ty, .. } => {
734724 if ty.is_closure() {
735 ("closure", closure_as_fn_str(infcx, ty), path)
725 ("closure", closure_as_fn_str(infcx, ty), long_ty_path)
736726 } else if !ty.is_ty_or_numeric_infer() {
737 ("normal", infcx.tcx.short_string(ty, &mut path), path)
727 ("normal", infcx.tcx.short_string(ty, &mut long_ty_path), long_ty_path)
738728 } else {
739 ("other", String::new(), path)
729 ("other", String::new(), long_ty_path)
740730 }
741731 }
742732 // FIXME: We should be able to add some additional info here.
743733 InferSourceKind::GenericArg { .. }
744 | InferSourceKind::FullyQualifiedMethodCall { .. } => ("other", String::new(), path),
734 | InferSourceKind::FullyQualifiedMethodCall { .. } => {
735 ("other", String::new(), long_ty_path)
736 }
745737 }
746738 }
747739}
compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs+29-28
......@@ -169,7 +169,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
169169
170170 let predicate = self.resolve_vars_if_possible(obligation.predicate);
171171 let span = obligation.cause.span;
172 let mut file = None;
172 let mut long_ty_path = None;
173173
174174 debug!(?predicate, obligation.cause.code = ?obligation.cause.code());
175175
......@@ -211,19 +211,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
211211 self.tcx.as_lang_item(trait_pred.def_id()),
212212 Some(LangItem::Sized | LangItem::MetaSized)
213213 ) {
214 match self.tainted_by_errors() {
215 None => {
216 let err = self.emit_inference_failure_err(
214 return match self.tainted_by_errors() {
215 None => self
216 .emit_inference_failure_err(
217217 obligation.cause.body_id,
218218 span,
219219 trait_pred.self_ty().skip_binder().into(),
220220 TypeAnnotationNeeded::E0282,
221221 false,
222 );
223 return err.emit();
224 }
225 Some(e) => return e,
226 }
222 )
223 .emit(),
224 Some(e) => e,
225 };
227226 }
228227
229228 // Typically, this ambiguity should only happen if
......@@ -260,8 +259,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
260259 span,
261260 E0283,
262261 "type annotations needed: cannot satisfy `{}`",
263 self.tcx.short_string(predicate, &mut file),
262 self.tcx.short_string(predicate, &mut long_ty_path),
264263 )
264 .with_long_ty_path(long_ty_path)
265265 };
266266
267267 let mut ambiguities = compute_applicable_impls_for_diagnostics(
......@@ -307,7 +307,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
307307 err.cancel();
308308 return e;
309309 }
310 let pred = self.tcx.short_string(predicate, &mut file);
310 let pred = self.tcx.short_string(predicate, &mut err.long_ty_path());
311311 err.note(format!("cannot satisfy `{pred}`"));
312312 let impl_candidates =
313313 self.find_similar_impl_candidates(predicate.as_trait_clause().unwrap());
......@@ -512,6 +512,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
512512 true,
513513 )
514514 }
515
515516 ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => {
516517 if let Err(e) = predicate.error_reported() {
517518 return e;
......@@ -536,7 +537,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
536537 .filter_map(ty::GenericArg::as_term)
537538 .chain([data.term])
538539 .find(|g| g.has_non_region_infer());
539 let predicate = self.tcx.short_string(predicate, &mut file);
540 let predicate = self.tcx.short_string(predicate, &mut long_ty_path);
540541 if let Some(term) = term {
541542 self.emit_inference_failure_err(
542543 obligation.cause.body_id,
......@@ -546,6 +547,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
546547 true,
547548 )
548549 .with_note(format!("cannot satisfy `{predicate}`"))
550 .with_long_ty_path(long_ty_path)
549551 } else {
550552 // If we can't find a generic parameter, just print a generic error
551553 struct_span_code_err!(
......@@ -555,6 +557,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
555557 "type annotations needed: cannot satisfy `{predicate}`",
556558 )
557559 .with_span_label(span, format!("cannot satisfy `{predicate}`"))
560 .with_long_ty_path(long_ty_path)
558561 }
559562 }
560563
......@@ -568,17 +571,16 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
568571 let term =
569572 data.walk().filter_map(ty::GenericArg::as_term).find(|term| term.is_infer());
570573 if let Some(term) = term {
571 let err = self.emit_inference_failure_err(
574 self.emit_inference_failure_err(
572575 obligation.cause.body_id,
573576 span,
574577 term,
575578 TypeAnnotationNeeded::E0284,
576579 true,
577 );
578 err
580 )
579581 } else {
580582 // If we can't find a generic parameter, just print a generic error
581 let predicate = self.tcx.short_string(predicate, &mut file);
583 let predicate = self.tcx.short_string(predicate, &mut long_ty_path);
582584 struct_span_code_err!(
583585 self.dcx(),
584586 span,
......@@ -586,6 +588,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
586588 "type annotations needed: cannot satisfy `{predicate}`",
587589 )
588590 .with_span_label(span, format!("cannot satisfy `{predicate}`"))
591 .with_long_ty_path(long_ty_path)
589592 }
590593 }
591594
......@@ -597,13 +600,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
597600 TypeAnnotationNeeded::E0284,
598601 true,
599602 ),
603
600604 ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })
601605 if term.is_infer() =>
602606 {
603607 if let Some(e) = self.tainted_by_errors() {
604608 return e;
605609 }
606 let alias = self.tcx.short_string(alias, &mut file);
610 let alias = self.tcx.short_string(alias, &mut long_ty_path);
607611 struct_span_code_err!(
608612 self.dcx(),
609613 span,
......@@ -611,37 +615,34 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
611615 "type annotations needed: cannot normalize `{alias}`",
612616 )
613617 .with_span_label(span, format!("cannot normalize `{alias}`"))
618 .with_long_ty_path(long_ty_path)
614619 }
620
615621 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(sym)) => {
616622 if let Some(e) = self.tainted_by_errors() {
617623 return e;
618624 }
619625
620 let mut err;
621
622626 if self.tcx.features().staged_api() {
623 err = self.dcx().struct_span_err(
627 self.dcx().struct_span_err(
624628 span,
625629 format!("unstable feature `{sym}` is used without being enabled."),
626 );
627
628 err.help(format!("The feature can be enabled by marking the current item with `#[unstable_feature_bound({sym})]`"));
630 ).with_help(format!("The feature can be enabled by marking the current item with `#[unstable_feature_bound({sym})]`"))
629631 } else {
630 err = feature_err_unstable_feature_bound(
632 feature_err_unstable_feature_bound(
631633 &self.tcx.sess,
632634 sym,
633635 span,
634636 format!("use of unstable library feature `{sym}`"),
635 );
637 )
636638 }
637 err
638639 }
639640
640641 _ => {
641642 if let Some(e) = self.tainted_by_errors() {
642643 return e;
643644 }
644 let predicate = self.tcx.short_string(predicate, &mut file);
645 let predicate = self.tcx.short_string(predicate, &mut long_ty_path);
645646 struct_span_code_err!(
646647 self.dcx(),
647648 span,
......@@ -649,9 +650,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
649650 "type annotations needed: cannot satisfy `{predicate}`",
650651 )
651652 .with_span_label(span, format!("cannot satisfy `{predicate}`"))
653 .with_long_ty_path(long_ty_path)
652654 }
653655 };
654 *err.long_ty_path() = file;
655656 self.note_obligation_cause(&mut err, obligation);
656657 err.emit()
657658 }
compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs+78-41
......@@ -208,16 +208,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
208208 performs a conversion on the error value \
209209 using the `From` trait";
210210 let (message, notes, append_const_msg) = if is_try_conversion {
211 let ty = self.tcx.short_string(
212 main_trait_predicate.skip_binder().self_ty(),
213 &mut long_ty_file,
214 );
211215 // We have a `-> Result<_, E1>` and `gives_E2()?`.
212216 (
213 Some(format!(
214 "`?` couldn't convert the error to `{}`",
215 main_trait_predicate.skip_binder().self_ty(),
216 )),
217 Some(format!("`?` couldn't convert the error to `{ty}`")),
217218 vec![question_mark_message.to_owned()],
218219 Some(AppendConstMessage::Default),
219220 )
220221 } else if is_question_mark {
222 let main_trait_predicate =
223 self.tcx.short_string(main_trait_predicate, &mut long_ty_file);
221224 // Similar to the case above, but in this case the conversion is for a
222225 // trait object: `-> Result<_, Box<dyn Error>` and `gives_E()?` when
223226 // `E: Error` isn't met.
......@@ -233,7 +236,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
233236 (message, notes, append_const_msg)
234237 };
235238
236 let err_msg = self.get_standard_error_message(
239 let default_err_msg = || self.get_standard_error_message(
237240 main_trait_predicate,
238241 message,
239242 None,
......@@ -258,7 +261,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
258261 );
259262 }
260263 GetSafeTransmuteErrorAndReason::Default => {
261 (err_msg, None)
264 (default_err_msg(), None)
262265 }
263266 GetSafeTransmuteErrorAndReason::Error {
264267 err_msg,
......@@ -266,7 +269,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
266269 } => (err_msg, safe_transmute_explanation),
267270 }
268271 } else {
269 (err_msg, None)
272 (default_err_msg(), None)
270273 };
271274
272275 let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg);
......@@ -279,15 +282,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
279282
280283 if let Some(ret_span) = self.return_type_span(&obligation) {
281284 if is_try_conversion {
285 let ty = self.tcx.short_string(
286 main_trait_predicate.skip_binder().self_ty(),
287 err.long_ty_path(),
288 );
282289 err.span_label(
283290 ret_span,
284 format!(
285 "expected `{}` because of this",
286 main_trait_predicate.skip_binder().self_ty()
287 ),
291 format!("expected `{ty}` because of this"),
288292 );
289293 } else if is_question_mark {
290 err.span_label(ret_span, format!("required `{main_trait_predicate}` because of this"));
294 let main_trait_predicate =
295 self.tcx.short_string(main_trait_predicate, err.long_ty_path());
296 err.span_label(
297 ret_span,
298 format!("required `{main_trait_predicate}` because of this"),
299 );
291300 }
292301 }
293302
......@@ -303,6 +312,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
303312 &obligation,
304313 leaf_trait_predicate,
305314 pre_message,
315 err.long_ty_path(),
306316 );
307317
308318 self.check_for_binding_assigned_block_without_tail_expression(
......@@ -414,11 +424,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
414424 } else {
415425 vec![(span.shrink_to_hi(), format!(" as {}", cand.self_ty()))]
416426 };
427 let trait_ = self.tcx.short_string(cand.print_trait_sugared(), err.long_ty_path());
428 let ty = self.tcx.short_string(cand.self_ty(), err.long_ty_path());
417429 err.multipart_suggestion(
418430 format!(
419 "the trait `{}` is implemented for fn pointer `{}`, try casting using `as`",
420 cand.print_trait_sugared(),
421 cand.self_ty(),
431 "the trait `{trait_}` is implemented for fn pointer \
432 `{ty}`, try casting using `as`",
422433 ),
423434 suggestion,
424435 Applicability::MaybeIncorrect,
......@@ -522,7 +533,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
522533 <https://github.com/rust-lang/rust/issues/48950> \
523534 for more information)",
524535 );
525 err.help("did you intend to use the type `()` here instead?");
536 err.help("you might have intended to use the type `()` here instead");
526537 }
527538 }
528539
......@@ -722,10 +733,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
722733 }
723734
724735 SelectionError::ConstArgHasWrongType { ct, ct_ty, expected_ty } => {
736 let expected_ty_str = self.tcx.short_string(expected_ty, &mut long_ty_file);
737 let ct_str = self.tcx.short_string(ct, &mut long_ty_file);
725738 let mut diag = self.dcx().struct_span_err(
726739 span,
727 format!("the constant `{ct}` is not of type `{expected_ty}`"),
740 format!("the constant `{ct_str}` is not of type `{expected_ty_str}`"),
728741 );
742 diag.long_ty_path = long_ty_file;
729743
730744 self.note_type_err(
731745 &mut diag,
......@@ -1118,9 +1132,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11181132 .must_apply_modulo_regions()
11191133 {
11201134 if !suggested {
1135 let err_ty = self.tcx.short_string(err_ty, err.long_ty_path());
11211136 err.span_label(span, format!("this has type `Result<_, {err_ty}>`"));
11221137 }
11231138 } else {
1139 let err_ty = self.tcx.short_string(err_ty, err.long_ty_path());
11241140 err.span_label(
11251141 span,
11261142 format!(
......@@ -1156,12 +1172,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11561172 );
11571173 }
11581174 (ty::Adt(def, _), None) if def.did().is_local() => {
1175 let trait_path = self.tcx.short_string(
1176 trait_pred.skip_binder().trait_ref.print_only_trait_path(),
1177 err.long_ty_path(),
1178 );
11591179 err.span_note(
11601180 self.tcx.def_span(def.did()),
1161 format!(
1162 "`{self_ty}` needs to implement `{}`",
1163 trait_pred.skip_binder().trait_ref.print_only_trait_path(),
1164 ),
1181 format!("`{self_ty}` needs to implement `{trait_path}`"),
11651182 );
11661183 }
11671184 (ty::Adt(def, _), Some(ty)) if def.did().is_local() => {
......@@ -1195,13 +1212,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
11951212 bug!()
11961213 };
11971214
1215 let mut file = None;
1216 let ty_str = self.tcx.short_string(ty, &mut file);
11981217 let mut diag = match ty.kind() {
11991218 ty::Float(_) => {
12001219 struct_span_code_err!(
12011220 self.dcx(),
12021221 span,
12031222 E0741,
1204 "`{ty}` is forbidden as the type of a const generic parameter",
1223 "`{ty_str}` is forbidden as the type of a const generic parameter",
12051224 )
12061225 }
12071226 ty::FnPtr(..) => {
......@@ -1226,7 +1245,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
12261245 self.dcx(),
12271246 span,
12281247 E0741,
1229 "`{ty}` must implement `ConstParamTy` to be used as the type of a const generic parameter",
1248 "`{ty_str}` must implement `ConstParamTy` to be used as the type of a const generic parameter",
12301249 );
12311250 // Only suggest derive if this isn't a derived obligation,
12321251 // and the struct is local.
......@@ -1258,21 +1277,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
12581277 self.dcx(),
12591278 span,
12601279 E0741,
1261 "`{ty}` can't be used as a const parameter type",
1280 "`{ty_str}` can't be used as a const parameter type",
12621281 )
12631282 }
12641283 };
1284 diag.long_ty_path = file;
12651285
12661286 let mut code = obligation.cause.code();
12671287 let mut pred = obligation.predicate.as_trait_clause();
12681288 while let Some((next_code, next_pred)) = code.parent_with_predicate() {
12691289 if let Some(pred) = pred {
12701290 self.enter_forall(pred, |pred| {
1271 diag.note(format!(
1272 "`{}` must implement `{}`, but it does not",
1273 pred.self_ty(),
1274 pred.print_modifiers_and_trait_path()
1275 ));
1291 let ty = self.tcx.short_string(pred.self_ty(), diag.long_ty_path());
1292 let trait_path = self
1293 .tcx
1294 .short_string(pred.print_modifiers_and_trait_path(), diag.long_ty_path());
1295 diag.note(format!("`{ty}` must implement `{trait_path}`, but it does not"));
12761296 })
12771297 }
12781298 code = next_code;
......@@ -1584,7 +1604,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
15841604 projection_term: ty::AliasTerm<'tcx>,
15851605 normalized_ty: ty::Term<'tcx>,
15861606 expected_ty: ty::Term<'tcx>,
1587 file: &mut Option<PathBuf>,
1607 long_ty_path: &mut Option<PathBuf>,
15881608 ) -> Option<(String, Span, Option<Span>)> {
15891609 let trait_def_id = projection_term.trait_def_id(self.tcx);
15901610 let self_ty = projection_term.self_ty();
......@@ -1624,17 +1644,25 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
16241644 };
16251645 let item = match self_ty.kind() {
16261646 ty::FnDef(def, _) => self.tcx.item_name(*def).to_string(),
1627 _ => self.tcx.short_string(self_ty, file),
1647 _ => self.tcx.short_string(self_ty, long_ty_path),
16281648 };
1649 let expected_ty = self.tcx.short_string(expected_ty, long_ty_path);
1650 let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path);
16291651 Some((format!(
16301652 "expected `{item}` to return `{expected_ty}`, but it returns `{normalized_ty}`",
16311653 ), span, closure_span))
16321654 } else if self.tcx.is_lang_item(trait_def_id, LangItem::Future) {
1655 let self_ty = self.tcx.short_string(self_ty, long_ty_path);
1656 let expected_ty = self.tcx.short_string(expected_ty, long_ty_path);
1657 let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path);
16331658 Some((format!(
16341659 "expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it \
16351660 resolves to `{normalized_ty}`"
16361661 ), span, None))
16371662 } else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) {
1663 let self_ty = self.tcx.short_string(self_ty, long_ty_path);
1664 let expected_ty = self.tcx.short_string(expected_ty, long_ty_path);
1665 let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path);
16381666 Some((format!(
16391667 "expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it \
16401668 yields `{normalized_ty}`"
......@@ -2097,12 +2125,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
20972125
20982126 if let [TypeError::Sorts(exp_found)] = &terrs[..] {
20992127 let exp_found = self.resolve_vars_if_possible(*exp_found);
2128 let expected =
2129 self.tcx.short_string(exp_found.expected, err.long_ty_path());
2130 let found = self.tcx.short_string(exp_found.found, err.long_ty_path());
21002131 err.highlighted_help(vec![
21012132 StringPart::normal("for that trait implementation, "),
21022133 StringPart::normal("expected `"),
2103 StringPart::highlighted(exp_found.expected.to_string()),
2134 StringPart::highlighted(expected),
21042135 StringPart::normal("`, found `"),
2105 StringPart::highlighted(exp_found.found.to_string()),
2136 StringPart::highlighted(found),
21062137 StringPart::normal("`"),
21072138 ]);
21082139 self.suggest_function_pointers_impl(None, &exp_found, err);
......@@ -2135,11 +2166,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21352166 (ty::FnPtr(..), _) => (" implemented for fn pointer `", ""),
21362167 _ => (" implemented for `", ""),
21372168 };
2169 let trait_ = self.tcx.short_string(cand.print_trait_sugared(), err.long_ty_path());
2170 let self_ty = self.tcx.short_string(cand.self_ty(), err.long_ty_path());
21382171 err.highlighted_help(vec![
2139 StringPart::normal(format!("the trait `{}` ", cand.print_trait_sugared())),
2172 StringPart::normal(format!("the trait `{trait_}` ",)),
21402173 StringPart::highlighted("is"),
21412174 StringPart::normal(desc),
2142 StringPart::highlighted(cand.self_ty().to_string()),
2175 StringPart::highlighted(self_ty),
21432176 StringPart::normal("`"),
21442177 StringPart::normal(mention_castable),
21452178 ]);
......@@ -2159,9 +2192,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
21592192 .into_iter()
21602193 .map(|c| {
21612194 if all_traits_equal {
2162 format!("\n {}", c.self_ty())
2195 format!("\n {}", self.tcx.short_string(c.self_ty(), err.long_ty_path()))
21632196 } else {
2164 format!("\n `{}` implements `{}`", c.self_ty(), c.print_only_trait_path())
2197 format!(
2198 "\n `{}` implements `{}`",
2199 self.tcx.short_string(c.self_ty(), err.long_ty_path()),
2200 self.tcx.short_string(c.print_only_trait_path(), err.long_ty_path()),
2201 )
21652202 }
21662203 })
21672204 .collect();
......@@ -2477,7 +2514,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
24772514 predicate_constness: Option<ty::BoundConstness>,
24782515 append_const_msg: Option<AppendConstMessage>,
24792516 post_message: String,
2480 long_ty_file: &mut Option<PathBuf>,
2517 long_ty_path: &mut Option<PathBuf>,
24812518 ) -> String {
24822519 message
24832520 .and_then(|cannot_do_this| {
......@@ -2503,7 +2540,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
25032540 "the trait bound `{}` is not satisfied{post_message}",
25042541 self.tcx.short_string(
25052542 trait_predicate.print_with_bound_constness(predicate_constness),
2506 long_ty_file,
2543 long_ty_path,
25072544 ),
25082545 )
25092546 })
......@@ -2608,8 +2645,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
26082645 dst_min_align,
26092646 } => {
26102647 format!(
2611 "the minimum alignment of `{src}` ({src_min_align}) should \
2612 be greater than that of `{dst}` ({dst_min_align})"
2648 "the minimum alignment of `{src}` ({src_min_align}) should be \
2649 greater than that of `{dst}` ({dst_min_align})"
26132650 )
26142651 }
26152652 rustc_transmute::Reason::DstIsMoreUnique => {
compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs+2-2
......@@ -99,7 +99,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
9999 &self,
100100 trait_pred: ty::PolyTraitPredicate<'tcx>,
101101 obligation: &PredicateObligation<'tcx>,
102 long_ty_file: &mut Option<PathBuf>,
102 long_ty_path: &mut Option<PathBuf>,
103103 ) -> OnUnimplementedNote {
104104 if trait_pred.polarity() != ty::PredicatePolarity::Positive {
105105 return OnUnimplementedNote::default();
......@@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
281281 GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
282282 if let Some(ty) = trait_pred.trait_ref.args[param.index as usize].as_type()
283283 {
284 self.tcx.short_string(ty, long_ty_file)
284 self.tcx.short_string(ty, long_ty_path)
285285 } else {
286286 trait_pred.trait_ref.args[param.index as usize].to_string()
287287 }
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs+43-24
......@@ -3,6 +3,7 @@
33use std::assert_matches::debug_assert_matches;
44use std::borrow::Cow;
55use std::iter;
6use std::path::PathBuf;
67
78use itertools::{EitherOrBoth, Itertools};
89use rustc_abi::ExternAbi;
......@@ -1369,6 +1370,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13691370 );
13701371 let self_ty_str =
13711372 self.tcx.short_string(old_pred.self_ty().skip_binder(), err.long_ty_path());
1373 let trait_path = self
1374 .tcx
1375 .short_string(old_pred.print_modifiers_and_trait_path(), err.long_ty_path());
1376
13721377 if has_custom_message {
13731378 err.note(msg);
13741379 } else {
......@@ -1376,10 +1381,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13761381 }
13771382 err.span_label(
13781383 span,
1379 format!(
1380 "the trait `{}` is not implemented for `{self_ty_str}`",
1381 old_pred.print_modifiers_and_trait_path()
1382 ),
1384 format!("the trait `{trait_path}` is not implemented for `{self_ty_str}`"),
13831385 );
13841386 };
13851387
......@@ -3333,17 +3335,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
33333335 tcx.async_fn_trait_kind_from_def_id(data.parent_trait_pred.def_id()).is_some();
33343336
33353337 if !is_upvar_tys_infer_tuple && !is_builtin_async_fn_trait {
3336 let ty_str = tcx.short_string(ty, err.long_ty_path());
3337 let msg = format!("required because it appears within the type `{ty_str}`");
3338 let mut msg = || {
3339 let ty_str = tcx.short_string(ty, err.long_ty_path());
3340 format!("required because it appears within the type `{ty_str}`")
3341 };
33383342 match ty.kind() {
3339 ty::Adt(def, _) => match tcx.opt_item_ident(def.did()) {
3340 Some(ident) => {
3341 err.span_note(ident.span, msg);
3342 }
3343 None => {
3344 err.note(msg);
3343 ty::Adt(def, _) => {
3344 let msg = msg();
3345 match tcx.opt_item_ident(def.did()) {
3346 Some(ident) => {
3347 err.span_note(ident.span, msg);
3348 }
3349 None => {
3350 err.note(msg);
3351 }
33453352 }
3346 },
3353 }
33473354 ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => {
33483355 // If the previous type is async fn, this is the future generated by the body of an async function.
33493356 // Avoid printing it twice (it was already printed in the `ty::Coroutine` arm below).
......@@ -3363,6 +3370,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
33633370 {
33643371 // See comment above; skip printing twice.
33653372 } else {
3373 let msg = msg();
33663374 err.span_note(tcx.def_span(def_id), msg);
33673375 }
33683376 }
......@@ -3392,6 +3400,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
33923400 err.note("`str` is considered to contain a `[u8]` slice for auto trait purposes");
33933401 }
33943402 _ => {
3403 let msg = msg();
33953404 err.note(msg);
33963405 }
33973406 };
......@@ -3441,7 +3450,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
34413450 }
34423451 let self_ty_str =
34433452 tcx.short_string(parent_trait_pred.skip_binder().self_ty(), err.long_ty_path());
3444 let trait_name = parent_trait_pred.print_modifiers_and_trait_path().to_string();
3453 let trait_name = tcx.short_string(
3454 parent_trait_pred.print_modifiers_and_trait_path(),
3455 err.long_ty_path(),
3456 );
34453457 let msg = format!("required for `{self_ty_str}` to implement `{trait_name}`");
34463458 let mut is_auto_trait = false;
34473459 match tcx.hir_get_if_local(data.impl_or_alias_def_id) {
......@@ -3539,10 +3551,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
35393551 parent_trait_pred.skip_binder().self_ty(),
35403552 err.long_ty_path(),
35413553 );
3542 err.note(format!(
3543 "required for `{self_ty}` to implement `{}`",
3544 parent_trait_pred.print_modifiers_and_trait_path()
3545 ));
3554 let trait_path = tcx.short_string(
3555 parent_trait_pred.print_modifiers_and_trait_path(),
3556 err.long_ty_path(),
3557 );
3558 err.note(format!("required for `{self_ty}` to implement `{trait_path}`"));
35463559 }
35473560 // #74711: avoid a stack overflow
35483561 ensure_sufficient_stack(|| {
......@@ -3558,15 +3571,20 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
35583571 });
35593572 }
35603573 ObligationCauseCode::ImplDerivedHost(ref data) => {
3561 let self_ty =
3562 self.resolve_vars_if_possible(data.derived.parent_host_pred.self_ty());
3563 let msg = format!(
3564 "required for `{self_ty}` to implement `{} {}`",
3565 data.derived.parent_host_pred.skip_binder().constness,
3574 let self_ty = tcx.short_string(
3575 self.resolve_vars_if_possible(data.derived.parent_host_pred.self_ty()),
3576 err.long_ty_path(),
3577 );
3578 let trait_path = tcx.short_string(
35663579 data.derived
35673580 .parent_host_pred
35683581 .map_bound(|pred| pred.trait_ref)
35693582 .print_only_trait_path(),
3583 err.long_ty_path(),
3584 );
3585 let msg = format!(
3586 "required for `{self_ty}` to implement `{} {trait_path}`",
3587 data.derived.parent_host_pred.skip_binder().constness,
35703588 );
35713589 match tcx.hir_get_if_local(data.impl_def_id) {
35723590 Some(Node::Item(hir::Item {
......@@ -5351,6 +5369,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53515369 obligation: &PredicateObligation<'tcx>,
53525370 trait_predicate: ty::PolyTraitPredicate<'tcx>,
53535371 pre_message: String,
5372 long_ty_path: &mut Option<PathBuf>,
53545373) -> String {
53555374 if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
53565375 "consider using `()`, or a `Result`".to_owned()
......@@ -5369,7 +5388,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
53695388 format!(
53705389 "{pre_message}the trait `{}` is not implemented for{desc} `{}`",
53715390 trait_predicate.print_modifiers_and_trait_path(),
5372 tcx.short_string(trait_predicate.self_ty().skip_binder(), &mut None),
5391 tcx.short_string(trait_predicate.self_ty().skip_binder(), long_ty_path),
53735392 )
53745393 } else {
53755394 // "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is
compiler/rustc_trait_selection/src/errors.rs-11
......@@ -1,5 +1,3 @@
1use std::path::PathBuf;
2
31use rustc_ast::Path;
42use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
53use rustc_errors::codes::*;
......@@ -224,9 +222,6 @@ pub struct AnnotationRequired<'a> {
224222 pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
225223 #[subdiagnostic]
226224 pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
227 #[note(trait_selection_full_type_written)]
228 pub was_written: bool,
229 pub path: PathBuf,
230225}
231226
232227// Copy of `AnnotationRequired` for E0283
......@@ -245,9 +240,6 @@ pub struct AmbiguousImpl<'a> {
245240 pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
246241 #[subdiagnostic]
247242 pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
248 #[note(trait_selection_full_type_written)]
249 pub was_written: bool,
250 pub path: PathBuf,
251243}
252244
253245// Copy of `AnnotationRequired` for E0284
......@@ -266,9 +258,6 @@ pub struct AmbiguousReturn<'a> {
266258 pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
267259 #[subdiagnostic]
268260 pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
269 #[note(trait_selection_full_type_written)]
270 pub was_written: bool,
271 pub path: PathBuf,
272261}
273262
274263// Used when a better one isn't available
compiler/rustc_type_ir/src/binder.rs+30-30
......@@ -15,13 +15,12 @@ use crate::lift::Lift;
1515use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
1616use crate::{self as ty, Interner};
1717
18/// Binder is a binder for higher-ranked lifetimes or types. It is part of the
18/// `Binder` is a binder for higher-ranked lifetimes or types. It is part of the
1919/// compiler's representation for things like `for<'a> Fn(&'a isize)`
20/// (which would be represented by the type `PolyTraitRef ==
21/// Binder<I, TraitRef>`). Note that when we instantiate,
22/// erase, or otherwise "discharge" these bound vars, we change the
23/// type from `Binder<I, T>` to just `T` (see
24/// e.g., `liberate_late_bound_regions`).
20/// (which would be represented by the type `PolyTraitRef == Binder<I, TraitRef>`).
21///
22/// See <https://rustc-dev-guide.rust-lang.org/ty_module/instantiating_binders.html>
23/// for more details.
2524///
2625/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
2726#[derive_where(Clone; I: Interner, T: Clone)]
......@@ -154,22 +153,19 @@ impl<I: Interner, T: TypeVisitable<I>> TypeSuperVisitable<I> for Binder<I, T> {
154153}
155154
156155impl<I: Interner, T> Binder<I, T> {
157 /// Skips the binder and returns the "bound" value. This is a
158 /// risky thing to do because it's easy to get confused about
159 /// De Bruijn indices and the like. It is usually better to
160 /// discharge the binder using `no_bound_vars` or
161 /// `instantiate_bound_regions` or something like
162 /// that. `skip_binder` is only valid when you are either
163 /// extracting data that has nothing to do with bound vars, you
164 /// are doing some sort of test that does not involve bound
165 /// regions, or you are being very careful about your depth
166 /// accounting.
156 /// Returns the value contained inside of this `for<'a>`. Accessing generic args
157 /// in the returned value is generally incorrect.
158 ///
159 /// Please read <https://rustc-dev-guide.rust-lang.org/ty_module/instantiating_binders.html>
160 /// before using this function. It is usually better to discharge the binder using
161 /// `no_bound_vars` or `instantiate_bound_regions` or something like that.
167162 ///
168 /// Some examples where `skip_binder` is reasonable:
163 /// `skip_binder` is only valid when you are either extracting data that does not reference
164 /// any generic arguments, e.g. a `DefId`, or when you're making sure you only pass the
165 /// value to things which can handle escaping bound vars.
169166 ///
170 /// - extracting the `DefId` from a PolyTraitRef;
171 /// - comparing the self type of a PolyTraitRef to see if it is equal to
172 /// a type parameter `X`, since the type `X` does not reference any regions
167 /// See existing uses of `.skip_binder()` in `rustc_trait_selection::traits::select`
168 /// or `rustc_next_trait_solver` for examples.
173169 pub fn skip_binder(self) -> T {
174170 self.value
175171 }
......@@ -355,12 +351,11 @@ impl<I: Interner> TypeVisitor<I> for ValidateBoundVars<I> {
355351 }
356352}
357353
358/// Similar to [`super::Binder`] except that it tracks early bound generics, i.e. `struct Foo<T>(T)`
354/// Similar to [`Binder`] except that it tracks early bound generics, i.e. `struct Foo<T>(T)`
359355/// needs `T` instantiated immediately. This type primarily exists to avoid forgetting to call
360356/// `instantiate`.
361357///
362/// If you don't have anything to `instantiate`, you may be looking for
363/// [`instantiate_identity`](EarlyBinder::instantiate_identity) or [`skip_binder`](EarlyBinder::skip_binder).
358/// See <https://rustc-dev-guide.rust-lang.org/ty_module/early_binder.html> for more details.
364359#[derive_where(Clone; I: Interner, T: Clone)]
365360#[derive_where(Copy; I: Interner, T: Copy)]
366361#[derive_where(PartialEq; I: Interner, T: PartialEq)]
......@@ -423,17 +418,22 @@ impl<I: Interner, T> EarlyBinder<I, T> {
423418 EarlyBinder { value, _tcx: PhantomData }
424419 }
425420
426 /// Skips the binder and returns the "bound" value.
427 /// This can be used to extract data that does not depend on generic parameters
428 /// (e.g., getting the `DefId` of the inner value or getting the number of
429 /// arguments of an `FnSig`). Otherwise, consider using
430 /// [`instantiate_identity`](EarlyBinder::instantiate_identity).
421 /// Skips the binder and returns the "bound" value. Accessing generic args
422 /// in the returned value is generally incorrect.
423 ///
424 /// Please read <https://rustc-dev-guide.rust-lang.org/ty_module/early_binder.html>
425 /// before using this function.
426 ///
427 /// Only use this to extract data that does not depend on generic parameters, e.g.
428 /// to get the `DefId` of the inner value or the number of arguments ofan `FnSig`,
429 /// or while making sure to only pass the value to functions which are explicitly
430 /// set up to handle these uninstantiated generic parameters.
431431 ///
432432 /// To skip the binder on `x: &EarlyBinder<I, T>` to obtain `&T`, leverage
433433 /// [`EarlyBinder::as_ref`](EarlyBinder::as_ref): `x.as_ref().skip_binder()`.
434434 ///
435 /// See also [`Binder::skip_binder`](super::Binder::skip_binder), which is
436 /// the analogous operation on [`super::Binder`].
435 /// See also [`Binder::skip_binder`](Binder::skip_binder), which is
436 /// the analogous operation on [`Binder`].
437437 pub fn skip_binder(self) -> T {
438438 self.value
439439 }
library/core/src/intrinsics/mod.rs+12-18
......@@ -150,69 +150,63 @@ pub unsafe fn atomic_xchg<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src:
150150
151151/// Adds to the current value, returning the previous value.
152152/// `T` must be an integer or pointer type.
153/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
154/// value stored at `*dst` will have the provenance of the old value stored there.
153/// `U` must be the same as `T` if that is an integer type, or `usize` if `T` is a pointer type.
155154///
156155/// The stabilized version of this intrinsic is available on the
157156/// [`atomic`] types via the `fetch_add` method. For example, [`AtomicIsize::fetch_add`].
158157#[rustc_intrinsic]
159158#[rustc_nounwind]
160pub unsafe fn atomic_xadd<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
159pub unsafe fn atomic_xadd<T: Copy, U: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T;
161160
162161/// Subtract from the current value, returning the previous value.
163162/// `T` must be an integer or pointer type.
164/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
165/// value stored at `*dst` will have the provenance of the old value stored there.
163/// `U` must be the same as `T` if that is an integer type, or `usize` if `T` is a pointer type.
166164///
167165/// The stabilized version of this intrinsic is available on the
168166/// [`atomic`] types via the `fetch_sub` method. For example, [`AtomicIsize::fetch_sub`].
169167#[rustc_intrinsic]
170168#[rustc_nounwind]
171pub unsafe fn atomic_xsub<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
169pub unsafe fn atomic_xsub<T: Copy, U: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T;
172170
173171/// Bitwise and with the current value, returning the previous value.
174172/// `T` must be an integer or pointer type.
175/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
176/// value stored at `*dst` will have the provenance of the old value stored there.
173/// `U` must be the same as `T` if that is an integer type, or `usize` if `T` is a pointer type.
177174///
178175/// The stabilized version of this intrinsic is available on the
179176/// [`atomic`] types via the `fetch_and` method. For example, [`AtomicBool::fetch_and`].
180177#[rustc_intrinsic]
181178#[rustc_nounwind]
182pub unsafe fn atomic_and<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
179pub unsafe fn atomic_and<T: Copy, U: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T;
183180
184181/// Bitwise nand with the current value, returning the previous value.
185182/// `T` must be an integer or pointer type.
186/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
187/// value stored at `*dst` will have the provenance of the old value stored there.
183/// `U` must be the same as `T` if that is an integer type, or `usize` if `T` is a pointer type.
188184///
189185/// The stabilized version of this intrinsic is available on the
190186/// [`AtomicBool`] type via the `fetch_nand` method. For example, [`AtomicBool::fetch_nand`].
191187#[rustc_intrinsic]
192188#[rustc_nounwind]
193pub unsafe fn atomic_nand<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
189pub unsafe fn atomic_nand<T: Copy, U: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T;
194190
195191/// Bitwise or with the current value, returning the previous value.
196192/// `T` must be an integer or pointer type.
197/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
198/// value stored at `*dst` will have the provenance of the old value stored there.
193/// `U` must be the same as `T` if that is an integer type, or `usize` if `T` is a pointer type.
199194///
200195/// The stabilized version of this intrinsic is available on the
201196/// [`atomic`] types via the `fetch_or` method. For example, [`AtomicBool::fetch_or`].
202197#[rustc_intrinsic]
203198#[rustc_nounwind]
204pub unsafe fn atomic_or<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
199pub unsafe fn atomic_or<T: Copy, U: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T;
205200
206201/// Bitwise xor with the current value, returning the previous value.
207202/// `T` must be an integer or pointer type.
208/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
209/// value stored at `*dst` will have the provenance of the old value stored there.
203/// `U` must be the same as `T` if that is an integer type, or `usize` if `T` is a pointer type.
210204///
211205/// The stabilized version of this intrinsic is available on the
212206/// [`atomic`] types via the `fetch_xor` method. For example, [`AtomicBool::fetch_xor`].
213207#[rustc_intrinsic]
214208#[rustc_nounwind]
215pub unsafe fn atomic_xor<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
209pub unsafe fn atomic_xor<T: Copy, U: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T;
216210
217211/// Maximum with the current value using a signed comparison.
218212/// `T` must be a signed integer type.
library/core/src/sync/atomic.rs+45-44
......@@ -2293,7 +2293,7 @@ impl<T> AtomicPtr<T> {
22932293 #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
22942294 pub fn fetch_byte_add(&self, val: usize, order: Ordering) -> *mut T {
22952295 // SAFETY: data races are prevented by atomic intrinsics.
2296 unsafe { atomic_add(self.p.get(), core::ptr::without_provenance_mut(val), order).cast() }
2296 unsafe { atomic_add(self.p.get(), val, order).cast() }
22972297 }
22982298
22992299 /// Offsets the pointer's address by subtracting `val` *bytes*, returning the
......@@ -2318,9 +2318,10 @@ impl<T> AtomicPtr<T> {
23182318 /// #![feature(strict_provenance_atomic_ptr)]
23192319 /// use core::sync::atomic::{AtomicPtr, Ordering};
23202320 ///
2321 /// let atom = AtomicPtr::<i64>::new(core::ptr::without_provenance_mut(1));
2322 /// assert_eq!(atom.fetch_byte_sub(1, Ordering::Relaxed).addr(), 1);
2323 /// assert_eq!(atom.load(Ordering::Relaxed).addr(), 0);
2321 /// let mut arr = [0i64, 1];
2322 /// let atom = AtomicPtr::<i64>::new(&raw mut arr[1]);
2323 /// assert_eq!(atom.fetch_byte_sub(8, Ordering::Relaxed).addr(), (&raw const arr[1]).addr());
2324 /// assert_eq!(atom.load(Ordering::Relaxed).addr(), (&raw const arr[0]).addr());
23242325 /// ```
23252326 #[inline]
23262327 #[cfg(target_has_atomic = "ptr")]
......@@ -2328,7 +2329,7 @@ impl<T> AtomicPtr<T> {
23282329 #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
23292330 pub fn fetch_byte_sub(&self, val: usize, order: Ordering) -> *mut T {
23302331 // SAFETY: data races are prevented by atomic intrinsics.
2331 unsafe { atomic_sub(self.p.get(), core::ptr::without_provenance_mut(val), order).cast() }
2332 unsafe { atomic_sub(self.p.get(), val, order).cast() }
23322333 }
23332334
23342335 /// Performs a bitwise "or" operation on the address of the current pointer,
......@@ -2379,7 +2380,7 @@ impl<T> AtomicPtr<T> {
23792380 #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
23802381 pub fn fetch_or(&self, val: usize, order: Ordering) -> *mut T {
23812382 // SAFETY: data races are prevented by atomic intrinsics.
2382 unsafe { atomic_or(self.p.get(), core::ptr::without_provenance_mut(val), order).cast() }
2383 unsafe { atomic_or(self.p.get(), val, order).cast() }
23832384 }
23842385
23852386 /// Performs a bitwise "and" operation on the address of the current
......@@ -2429,7 +2430,7 @@ impl<T> AtomicPtr<T> {
24292430 #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
24302431 pub fn fetch_and(&self, val: usize, order: Ordering) -> *mut T {
24312432 // SAFETY: data races are prevented by atomic intrinsics.
2432 unsafe { atomic_and(self.p.get(), core::ptr::without_provenance_mut(val), order).cast() }
2433 unsafe { atomic_and(self.p.get(), val, order).cast() }
24332434 }
24342435
24352436 /// Performs a bitwise "xor" operation on the address of the current
......@@ -2477,7 +2478,7 @@ impl<T> AtomicPtr<T> {
24772478 #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
24782479 pub fn fetch_xor(&self, val: usize, order: Ordering) -> *mut T {
24792480 // SAFETY: data races are prevented by atomic intrinsics.
2480 unsafe { atomic_xor(self.p.get(), core::ptr::without_provenance_mut(val), order).cast() }
2481 unsafe { atomic_xor(self.p.get(), val, order).cast() }
24812482 }
24822483
24832484 /// Returns a mutable pointer to the underlying pointer.
......@@ -3981,15 +3982,15 @@ unsafe fn atomic_swap<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
39813982#[inline]
39823983#[cfg(target_has_atomic)]
39833984#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
3984unsafe fn atomic_add<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
3985unsafe fn atomic_add<T: Copy, U: Copy>(dst: *mut T, val: U, order: Ordering) -> T {
39853986 // SAFETY: the caller must uphold the safety contract for `atomic_add`.
39863987 unsafe {
39873988 match order {
3988 Relaxed => intrinsics::atomic_xadd::<T, { AO::Relaxed }>(dst, val),
3989 Acquire => intrinsics::atomic_xadd::<T, { AO::Acquire }>(dst, val),
3990 Release => intrinsics::atomic_xadd::<T, { AO::Release }>(dst, val),
3991 AcqRel => intrinsics::atomic_xadd::<T, { AO::AcqRel }>(dst, val),
3992 SeqCst => intrinsics::atomic_xadd::<T, { AO::SeqCst }>(dst, val),
3989 Relaxed => intrinsics::atomic_xadd::<T, U, { AO::Relaxed }>(dst, val),
3990 Acquire => intrinsics::atomic_xadd::<T, U, { AO::Acquire }>(dst, val),
3991 Release => intrinsics::atomic_xadd::<T, U, { AO::Release }>(dst, val),
3992 AcqRel => intrinsics::atomic_xadd::<T, U, { AO::AcqRel }>(dst, val),
3993 SeqCst => intrinsics::atomic_xadd::<T, U, { AO::SeqCst }>(dst, val),
39933994 }
39943995 }
39953996}
......@@ -3998,15 +3999,15 @@ unsafe fn atomic_add<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
39983999#[inline]
39994000#[cfg(target_has_atomic)]
40004001#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
4001unsafe fn atomic_sub<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
4002unsafe fn atomic_sub<T: Copy, U: Copy>(dst: *mut T, val: U, order: Ordering) -> T {
40024003 // SAFETY: the caller must uphold the safety contract for `atomic_sub`.
40034004 unsafe {
40044005 match order {
4005 Relaxed => intrinsics::atomic_xsub::<T, { AO::Relaxed }>(dst, val),
4006 Acquire => intrinsics::atomic_xsub::<T, { AO::Acquire }>(dst, val),
4007 Release => intrinsics::atomic_xsub::<T, { AO::Release }>(dst, val),
4008 AcqRel => intrinsics::atomic_xsub::<T, { AO::AcqRel }>(dst, val),
4009 SeqCst => intrinsics::atomic_xsub::<T, { AO::SeqCst }>(dst, val),
4006 Relaxed => intrinsics::atomic_xsub::<T, U, { AO::Relaxed }>(dst, val),
4007 Acquire => intrinsics::atomic_xsub::<T, U, { AO::Acquire }>(dst, val),
4008 Release => intrinsics::atomic_xsub::<T, U, { AO::Release }>(dst, val),
4009 AcqRel => intrinsics::atomic_xsub::<T, U, { AO::AcqRel }>(dst, val),
4010 SeqCst => intrinsics::atomic_xsub::<T, U, { AO::SeqCst }>(dst, val),
40104011 }
40114012 }
40124013}
......@@ -4147,15 +4148,15 @@ unsafe fn atomic_compare_exchange_weak<T: Copy>(
41474148#[inline]
41484149#[cfg(target_has_atomic)]
41494150#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
4150unsafe fn atomic_and<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
4151unsafe fn atomic_and<T: Copy, U: Copy>(dst: *mut T, val: U, order: Ordering) -> T {
41514152 // SAFETY: the caller must uphold the safety contract for `atomic_and`
41524153 unsafe {
41534154 match order {
4154 Relaxed => intrinsics::atomic_and::<T, { AO::Relaxed }>(dst, val),
4155 Acquire => intrinsics::atomic_and::<T, { AO::Acquire }>(dst, val),
4156 Release => intrinsics::atomic_and::<T, { AO::Release }>(dst, val),
4157 AcqRel => intrinsics::atomic_and::<T, { AO::AcqRel }>(dst, val),
4158 SeqCst => intrinsics::atomic_and::<T, { AO::SeqCst }>(dst, val),
4155 Relaxed => intrinsics::atomic_and::<T, U, { AO::Relaxed }>(dst, val),
4156 Acquire => intrinsics::atomic_and::<T, U, { AO::Acquire }>(dst, val),
4157 Release => intrinsics::atomic_and::<T, U, { AO::Release }>(dst, val),
4158 AcqRel => intrinsics::atomic_and::<T, U, { AO::AcqRel }>(dst, val),
4159 SeqCst => intrinsics::atomic_and::<T, U, { AO::SeqCst }>(dst, val),
41594160 }
41604161 }
41614162}
......@@ -4163,15 +4164,15 @@ unsafe fn atomic_and<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
41634164#[inline]
41644165#[cfg(target_has_atomic)]
41654166#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
4166unsafe fn atomic_nand<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
4167unsafe fn atomic_nand<T: Copy, U: Copy>(dst: *mut T, val: U, order: Ordering) -> T {
41674168 // SAFETY: the caller must uphold the safety contract for `atomic_nand`
41684169 unsafe {
41694170 match order {
4170 Relaxed => intrinsics::atomic_nand::<T, { AO::Relaxed }>(dst, val),
4171 Acquire => intrinsics::atomic_nand::<T, { AO::Acquire }>(dst, val),
4172 Release => intrinsics::atomic_nand::<T, { AO::Release }>(dst, val),
4173 AcqRel => intrinsics::atomic_nand::<T, { AO::AcqRel }>(dst, val),
4174 SeqCst => intrinsics::atomic_nand::<T, { AO::SeqCst }>(dst, val),
4171 Relaxed => intrinsics::atomic_nand::<T, U, { AO::Relaxed }>(dst, val),
4172 Acquire => intrinsics::atomic_nand::<T, U, { AO::Acquire }>(dst, val),
4173 Release => intrinsics::atomic_nand::<T, U, { AO::Release }>(dst, val),
4174 AcqRel => intrinsics::atomic_nand::<T, U, { AO::AcqRel }>(dst, val),
4175 SeqCst => intrinsics::atomic_nand::<T, U, { AO::SeqCst }>(dst, val),
41754176 }
41764177 }
41774178}
......@@ -4179,15 +4180,15 @@ unsafe fn atomic_nand<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
41794180#[inline]
41804181#[cfg(target_has_atomic)]
41814182#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
4182unsafe fn atomic_or<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
4183unsafe fn atomic_or<T: Copy, U: Copy>(dst: *mut T, val: U, order: Ordering) -> T {
41834184 // SAFETY: the caller must uphold the safety contract for `atomic_or`
41844185 unsafe {
41854186 match order {
4186 SeqCst => intrinsics::atomic_or::<T, { AO::SeqCst }>(dst, val),
4187 Acquire => intrinsics::atomic_or::<T, { AO::Acquire }>(dst, val),
4188 Release => intrinsics::atomic_or::<T, { AO::Release }>(dst, val),
4189 AcqRel => intrinsics::atomic_or::<T, { AO::AcqRel }>(dst, val),
4190 Relaxed => intrinsics::atomic_or::<T, { AO::Relaxed }>(dst, val),
4187 SeqCst => intrinsics::atomic_or::<T, U, { AO::SeqCst }>(dst, val),
4188 Acquire => intrinsics::atomic_or::<T, U, { AO::Acquire }>(dst, val),
4189 Release => intrinsics::atomic_or::<T, U, { AO::Release }>(dst, val),
4190 AcqRel => intrinsics::atomic_or::<T, U, { AO::AcqRel }>(dst, val),
4191 Relaxed => intrinsics::atomic_or::<T, U, { AO::Relaxed }>(dst, val),
41914192 }
41924193 }
41934194}
......@@ -4195,15 +4196,15 @@ unsafe fn atomic_or<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
41954196#[inline]
41964197#[cfg(target_has_atomic)]
41974198#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
4198unsafe fn atomic_xor<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
4199unsafe fn atomic_xor<T: Copy, U: Copy>(dst: *mut T, val: U, order: Ordering) -> T {
41994200 // SAFETY: the caller must uphold the safety contract for `atomic_xor`
42004201 unsafe {
42014202 match order {
4202 SeqCst => intrinsics::atomic_xor::<T, { AO::SeqCst }>(dst, val),
4203 Acquire => intrinsics::atomic_xor::<T, { AO::Acquire }>(dst, val),
4204 Release => intrinsics::atomic_xor::<T, { AO::Release }>(dst, val),
4205 AcqRel => intrinsics::atomic_xor::<T, { AO::AcqRel }>(dst, val),
4206 Relaxed => intrinsics::atomic_xor::<T, { AO::Relaxed }>(dst, val),
4203 SeqCst => intrinsics::atomic_xor::<T, U, { AO::SeqCst }>(dst, val),
4204 Acquire => intrinsics::atomic_xor::<T, U, { AO::Acquire }>(dst, val),
4205 Release => intrinsics::atomic_xor::<T, U, { AO::Release }>(dst, val),
4206 AcqRel => intrinsics::atomic_xor::<T, U, { AO::AcqRel }>(dst, val),
4207 Relaxed => intrinsics::atomic_xor::<T, U, { AO::Relaxed }>(dst, val),
42074208 }
42084209 }
42094210}
src/doc/rustc/src/platform-support/apple-ios-macabi.md+11
......@@ -56,6 +56,17 @@ Rust programs can be built for these targets by specifying `--target`, if
5656$ rustc --target aarch64-apple-ios-macabi your-code.rs
5757```
5858
59The target can be differentiated from the iOS targets with the
60`target_env = "macabi"` cfg (or `target_abi = "macabi"` before Rust CURRENT_RUSTC_VERSION).
61
62```rust
63if cfg!(target_env = "macabi") {
64 // Do something only on Mac Catalyst.
65}
66```
67
68This is similar to the `TARGET_OS_MACCATALYST` define in C code.
69
5970## Testing
6071
6172Mac Catalyst binaries can be run directly on macOS 10.15 Catalina or newer.
src/doc/rustc/src/platform-support/apple-ios.md+14
......@@ -66,6 +66,20 @@ Rust programs can be built for these targets by specifying `--target`, if
6666$ rustc --target aarch64-apple-ios your-code.rs
6767```
6868
69The simulator variants can be differentiated from the variants running
70on-device with the `target_env = "sim"` cfg (or `target_abi = "sim"` before
71Rust CURRENT_RUSTC_VERSION).
72
73```rust
74if cfg!(all(target_vendor = "apple", target_env = "sim")) {
75 // Do something on the iOS/tvOS/visionOS/watchOS Simulator.
76} {
77 // Everything else, like Windows and non-Simulator iOS.
78}
79```
80
81This is similar to the `TARGET_OS_SIMULATOR` define in C code.
82
6983## Testing
7084
7185There is no support for running the Rust or standard library testsuite at the
src/tools/compiletest/src/directives/tests.rs+2-5
......@@ -637,6 +637,7 @@ fn matches_env() {
637637 ("x86_64-unknown-linux-gnu", "gnu"),
638638 ("x86_64-fortanix-unknown-sgx", "sgx"),
639639 ("arm-unknown-linux-musleabi", "musl"),
640 ("aarch64-apple-ios-macabi", "macabi"),
640641 ];
641642 for (target, env) in envs {
642643 let config: Config = cfg().target(target).build();
......@@ -647,11 +648,7 @@ fn matches_env() {
647648
648649#[test]
649650fn matches_abi() {
650 let abis = [
651 ("aarch64-apple-ios-macabi", "macabi"),
652 ("x86_64-unknown-linux-gnux32", "x32"),
653 ("arm-unknown-linux-gnueabi", "eabi"),
654 ];
651 let abis = [("x86_64-unknown-linux-gnux32", "x32"), ("arm-unknown-linux-gnueabi", "eabi")];
655652 for (target, abi) in abis {
656653 let config: Config = cfg().target(target).build();
657654 assert!(config.matches_abi(abi), "{target} {abi}");
src/tools/miri/src/intrinsics/atomic.rs+9-10
......@@ -105,27 +105,27 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
105105 }
106106
107107 "or" => {
108 let ord = get_ord_at(1);
108 let ord = get_ord_at(2);
109109 this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), rw_ord(ord))?;
110110 }
111111 "xor" => {
112 let ord = get_ord_at(1);
112 let ord = get_ord_at(2);
113113 this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), rw_ord(ord))?;
114114 }
115115 "and" => {
116 let ord = get_ord_at(1);
116 let ord = get_ord_at(2);
117117 this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), rw_ord(ord))?;
118118 }
119119 "nand" => {
120 let ord = get_ord_at(1);
120 let ord = get_ord_at(2);
121121 this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), rw_ord(ord))?;
122122 }
123123 "xadd" => {
124 let ord = get_ord_at(1);
124 let ord = get_ord_at(2);
125125 this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), rw_ord(ord))?;
126126 }
127127 "xsub" => {
128 let ord = get_ord_at(1);
128 let ord = get_ord_at(2);
129129 this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), rw_ord(ord))?;
130130 }
131131 "min" => {
......@@ -231,15 +231,14 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
231231 let place = this.deref_pointer(place)?;
232232 let rhs = this.read_immediate(rhs)?;
233233
234 if !place.layout.ty.is_integral() && !place.layout.ty.is_raw_ptr() {
234 if !(place.layout.ty.is_integral() || place.layout.ty.is_raw_ptr())
235 || !(rhs.layout.ty.is_integral() || rhs.layout.ty.is_raw_ptr())
236 {
235237 span_bug!(
236238 this.cur_span(),
237239 "atomic arithmetic operations only work on integer and raw pointer types",
238240 );
239241 }
240 if rhs.layout.ty != place.layout.ty {
241 span_bug!(this.cur_span(), "atomic arithmetic operation type mismatch");
242 }
243242
244243 let old = match atomic_op {
245244 AtomicOp::Min =>
src/tools/miri/src/operator.rs+2-6
......@@ -50,17 +50,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5050 }
5151
5252 // Some more operations are possible with atomics.
53 // The return value always has the provenance of the *left* operand.
53 // The RHS must be `usize`.
5454 Add | Sub | BitOr | BitAnd | BitXor => {
5555 assert!(left.layout.ty.is_raw_ptr());
56 assert!(right.layout.ty.is_raw_ptr());
56 assert_eq!(right.layout.ty, this.tcx.types.usize);
5757 let ptr = left.to_scalar().to_pointer(this)?;
5858 // We do the actual operation with usize-typed scalars.
5959 let left = ImmTy::from_uint(ptr.addr().bytes(), this.machine.layouts.usize);
60 let right = ImmTy::from_uint(
61 right.to_scalar().to_target_usize(this)?,
62 this.machine.layouts.usize,
63 );
6460 let result = this.binary_op(bin_op, &left, &right)?;
6561 // Construct a new pointer with the provenance of `ptr` (the LHS).
6662 let result_ptr = Pointer::new(
src/tools/miri/tests/fail/alloc/alloc_error_handler_custom.stderr+1-1
......@@ -11,7 +11,7 @@ note: inside `_::__rg_oom`
1111 --> tests/fail/alloc/alloc_error_handler_custom.rs:LL:CC
1212 |
1313LL | #[alloc_error_handler]
14 | ---------------------- in this procedural macro expansion
14 | ---------------------- in this attribute macro expansion
1515LL | fn alloc_error_handler(layout: Layout) -> ! {
1616 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717 = note: inside `alloc::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
tests/codegen-llvm/atomicptr.rs+3-3
......@@ -1,5 +1,5 @@
11// LLVM does not support some atomic RMW operations on pointers, so inside codegen we lower those
2// to integer atomics, surrounded by casts to and from integer type.
2// to integer atomics, followed by an inttoptr cast.
33// This test ensures that we do the round-trip correctly for AtomicPtr::fetch_byte_add, and also
44// ensures that we do not have such a round-trip for AtomicPtr::swap, because LLVM supports pointer
55// arguments to `atomicrmw xchg`.
......@@ -20,8 +20,8 @@ pub fn helper(_: usize) {}
2020// CHECK-LABEL: @atomicptr_fetch_byte_add
2121#[no_mangle]
2222pub fn atomicptr_fetch_byte_add(a: &AtomicPtr<u8>, v: usize) -> *mut u8 {
23 // CHECK: %[[INTPTR:.*]] = ptrtoint ptr %{{.*}} to [[USIZE]]
24 // CHECK-NEXT: %[[RET:.*]] = atomicrmw add ptr %{{.*}}, [[USIZE]] %[[INTPTR]]
23 // CHECK: llvm.lifetime.start
24 // CHECK-NEXT: %[[RET:.*]] = atomicrmw add ptr %{{.*}}, [[USIZE]] %v
2525 // CHECK-NEXT: inttoptr [[USIZE]] %[[RET]] to ptr
2626 a.fetch_byte_add(v, Relaxed)
2727}
tests/run-make/atomic-lock-free/atomic_lock_free.rs+25-14
......@@ -14,7 +14,7 @@ pub enum AtomicOrdering {
1414}
1515
1616#[rustc_intrinsic]
17unsafe fn atomic_xadd<T, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
17unsafe fn atomic_xadd<T, U, const ORD: AtomicOrdering>(dst: *mut T, src: U) -> T;
1818
1919#[lang = "pointee_sized"]
2020pub trait PointeeSized {}
......@@ -35,51 +35,62 @@ impl<T: ?Sized> Copy for *mut T {}
3535impl ConstParamTy for AtomicOrdering {}
3636
3737#[cfg(target_has_atomic = "8")]
38#[unsafe(no_mangle)] // let's make sure we actually generate a symbol to check
3839pub unsafe fn atomic_u8(x: *mut u8) {
39 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
40 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
40 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u8);
4141}
4242#[cfg(target_has_atomic = "8")]
43#[unsafe(no_mangle)]
4344pub unsafe fn atomic_i8(x: *mut i8) {
44 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
45 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i8);
4546}
4647#[cfg(target_has_atomic = "16")]
48#[unsafe(no_mangle)]
4749pub unsafe fn atomic_u16(x: *mut u16) {
48 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
50 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u16);
4951}
5052#[cfg(target_has_atomic = "16")]
53#[unsafe(no_mangle)]
5154pub unsafe fn atomic_i16(x: *mut i16) {
52 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
55 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i16);
5356}
5457#[cfg(target_has_atomic = "32")]
58#[unsafe(no_mangle)]
5559pub unsafe fn atomic_u32(x: *mut u32) {
56 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
60 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u32);
5761}
5862#[cfg(target_has_atomic = "32")]
63#[unsafe(no_mangle)]
5964pub unsafe fn atomic_i32(x: *mut i32) {
60 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
65 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i32);
6166}
6267#[cfg(target_has_atomic = "64")]
68#[unsafe(no_mangle)]
6369pub unsafe fn atomic_u64(x: *mut u64) {
64 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
70 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u64);
6571}
6672#[cfg(target_has_atomic = "64")]
73#[unsafe(no_mangle)]
6774pub unsafe fn atomic_i64(x: *mut i64) {
68 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
75 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i64);
6976}
7077#[cfg(target_has_atomic = "128")]
78#[unsafe(no_mangle)]
7179pub unsafe fn atomic_u128(x: *mut u128) {
72 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
80 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1u128);
7381}
7482#[cfg(target_has_atomic = "128")]
83#[unsafe(no_mangle)]
7584pub unsafe fn atomic_i128(x: *mut i128) {
76 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
85 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1i128);
7786}
7887#[cfg(target_has_atomic = "ptr")]
88#[unsafe(no_mangle)]
7989pub unsafe fn atomic_usize(x: *mut usize) {
80 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
90 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1usize);
8191}
8292#[cfg(target_has_atomic = "ptr")]
93#[unsafe(no_mangle)]
8394pub unsafe fn atomic_isize(x: *mut isize) {
84 atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
95 atomic_xadd::<_, _, { AtomicOrdering::SeqCst }>(x, 1isize);
8596}
tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr+2-2
......@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22 --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1
33 |
44LL | #[alloc_error_handler]
5 | ---------------------- in this procedural macro expansion
5 | ---------------------- in this attribute macro expansion
66LL | // fn oom(
77LL | || info: &Layout,
88LL | || ) -> ()
......@@ -23,7 +23,7 @@ error[E0308]: mismatched types
2323 --> $DIR/alloc-error-handler-bad-signature-1.rs:10:1
2424 |
2525LL | #[alloc_error_handler]
26 | ---------------------- in this procedural macro expansion
26 | ---------------------- in this attribute macro expansion
2727LL | // fn oom(
2828LL | || info: &Layout,
2929LL | || ) -> ()
tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr+2-2
......@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22 --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1
33 |
44LL | #[alloc_error_handler]
5 | ---------------------- in this procedural macro expansion
5 | ---------------------- in this attribute macro expansion
66LL | // fn oom(
77LL | || info: Layout,
88LL | || ) {
......@@ -31,7 +31,7 @@ error[E0308]: mismatched types
3131 --> $DIR/alloc-error-handler-bad-signature-2.rs:10:1
3232 |
3333LL | #[alloc_error_handler]
34 | ---------------------- in this procedural macro expansion
34 | ---------------------- in this attribute macro expansion
3535LL | // fn oom(
3636LL | || info: Layout,
3737LL | || ) {
tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr+1-1
......@@ -2,7 +2,7 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
22 --> $DIR/alloc-error-handler-bad-signature-3.rs:10:1
33 |
44LL | #[alloc_error_handler]
5 | ---------------------- in this procedural macro expansion
5 | ---------------------- in this attribute macro expansion
66LL | fn oom() -> ! {
77 | _-^^^^^^^^^^^^
88LL | | loop {}
tests/ui/allocator/not-an-allocator.stderr+4-4
......@@ -2,7 +2,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
22 --> $DIR/not-an-allocator.rs:2:11
33 |
44LL | #[global_allocator]
5 | ------------------- in this procedural macro expansion
5 | ------------------- in this attribute macro expansion
66LL | static A: usize = 0;
77 | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
88 |
......@@ -12,7 +12,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
1212 --> $DIR/not-an-allocator.rs:2:11
1313 |
1414LL | #[global_allocator]
15 | ------------------- in this procedural macro expansion
15 | ------------------- in this attribute macro expansion
1616LL | static A: usize = 0;
1717 | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
1818 |
......@@ -23,7 +23,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
2323 --> $DIR/not-an-allocator.rs:2:11
2424 |
2525LL | #[global_allocator]
26 | ------------------- in this procedural macro expansion
26 | ------------------- in this attribute macro expansion
2727LL | static A: usize = 0;
2828 | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
2929 |
......@@ -34,7 +34,7 @@ error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
3434 --> $DIR/not-an-allocator.rs:2:11
3535 |
3636LL | #[global_allocator]
37 | ------------------- in this procedural macro expansion
37 | ------------------- in this attribute macro expansion
3838LL | static A: usize = 0;
3939 | ^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
4040 |
tests/ui/allocator/two-allocators.stderr+1-1
......@@ -4,7 +4,7 @@ error: cannot define multiple global allocators
44LL | static A: System = System;
55 | -------------------------- previous global allocator defined here
66LL | #[global_allocator]
7 | ------------------- in this procedural macro expansion
7 | ------------------- in this attribute macro expansion
88LL | static B: System = System;
99 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot define a new global allocator
1010
tests/ui/attributes/rustc_confusables_std_cases.stderr+3-3
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `push` found for struct `BTreeSet` in the current scope
1error[E0599]: no method named `push` found for struct `BTreeSet<T, A>` in the current scope
22 --> $DIR/rustc_confusables_std_cases.rs:6:7
33 |
44LL | x.push(1);
......@@ -22,7 +22,7 @@ LL - x.push_back(1);
2222LL + x.push(1);
2323 |
2424
25error[E0599]: no method named `push` found for struct `VecDeque` in the current scope
25error[E0599]: no method named `push` found for struct `VecDeque<T, A>` in the current scope
2626 --> $DIR/rustc_confusables_std_cases.rs:12:7
2727 |
2828LL | x.push(1);
......@@ -35,7 +35,7 @@ LL | let mut x = Vec::new();
3535 | ^^^^^ `x` of type `Vec<_>` that has method `push` defined earlier here
3636...
3737LL | let mut x = VecDeque::new();
38 | ----- earlier `x` shadowed here with type `VecDeque`
38 | ----- earlier `x` shadowed here with type `VecDeque<_>`
3939help: you might have meant to use `push_back`
4040 |
4141LL | x.push_back(1);
tests/ui/check-cfg/well-known-values.stderr+1-1
......@@ -156,7 +156,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
156156LL | target_env = "_UNEXPECTED_VALUE",
157157 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
158158 |
159 = note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `nto80`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, `uclibc`, and `v5`
159 = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `nto80`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5`
160160 = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
161161
162162warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
tests/ui/codegen/overflow-during-mono.rs+2-1
......@@ -1,5 +1,6 @@
1//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: FnMut(&'a _)`
1//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)`
22//@ build-fail
3//@ compile-flags: -Zwrite-long-types-to-disk=yes
34
45#![recursion_limit = "32"]
56
tests/ui/codegen/overflow-during-mono.stderr+6-4
......@@ -1,10 +1,12 @@
1error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: FnMut(&'a _)`
1error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)`
22 |
33 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "64"]` attribute to your crate (`overflow_during_mono`)
4 = note: required for `Filter<std::array::IntoIter<i32, 11>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator`
4 = note: required for `Filter<IntoIter<i32, 11>, {closure@overflow-during-mono.rs:14:41}>` to implement `Iterator`
55 = note: 31 redundant requirements hidden
6 = note: required for `Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<std::array::IntoIter<i32, 11>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator`
7 = note: required for `Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<std::array::IntoIter<i32, 11>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `IntoIterator`
6 = note: required for `Filter<Filter<Filter<Filter<Filter<..., ...>, ...>, ...>, ...>, ...>` to implement `Iterator`
7 = note: required for `Filter<Filter<Filter<Filter<Filter<..., ...>, ...>, ...>, ...>, ...>` to implement `IntoIterator`
8 = note: the full name for the type has been written to '$TEST_BUILD_DIR/overflow-during-mono.long-type-$LONG_TYPE_HASH.txt'
9 = note: consider using `--verbose` to print the full type name to the console
810
911error: aborting due to 1 previous error
1012
tests/ui/coherence/coherence-tuple-conflict.stderr+2
......@@ -12,6 +12,8 @@ error[E0609]: no field `dummy` on type `&(A, B)`
1212 |
1313LL | fn get(&self) -> usize { self.dummy }
1414 | ^^^^^ unknown field
15 |
16 = note: available fields are: `0`, `1`
1517
1618error: aborting due to 2 previous errors
1719
tests/ui/confuse-field-and-method/issue-18343.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `closure` found for struct `Obj` in the current scope
1error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
22 --> $DIR/issue-18343.rs:7:7
33 |
44LL | struct Obj<F> where F: FnMut() -> u32 {
tests/ui/confuse-field-and-method/issue-2392.stderr+6-6
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `closure` found for struct `Obj` in the current scope
1error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
22 --> $DIR/issue-2392.rs:36:15
33 |
44LL | struct Obj<F> where F: FnOnce() -> u32 {
......@@ -12,7 +12,7 @@ help: to call the closure stored in `closure`, surround the field access with pa
1212LL | (o_closure.closure)();
1313 | + +
1414
15error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope
15error[E0599]: no method named `not_closure` found for struct `Obj<F>` in the current scope
1616 --> $DIR/issue-2392.rs:38:15
1717 |
1818LL | struct Obj<F> where F: FnOnce() -> u32 {
......@@ -23,7 +23,7 @@ LL | o_closure.not_closure();
2323 | |
2424 | field, not a method
2525
26error[E0599]: no method named `closure` found for struct `Obj` in the current scope
26error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
2727 --> $DIR/issue-2392.rs:42:12
2828 |
2929LL | struct Obj<F> where F: FnOnce() -> u32 {
......@@ -65,7 +65,7 @@ help: to call the trait object stored in `boxed_closure`, surround the field acc
6565LL | (boxed_closure.boxed_closure)();
6666 | + +
6767
68error[E0599]: no method named `closure` found for struct `Obj` in the current scope
68error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
6969 --> $DIR/issue-2392.rs:53:12
7070 |
7171LL | struct Obj<F> where F: FnOnce() -> u32 {
......@@ -79,7 +79,7 @@ help: to call the function stored in `closure`, surround the field access with p
7979LL | (w.wrap.closure)();
8080 | + +
8181
82error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope
82error[E0599]: no method named `not_closure` found for struct `Obj<F>` in the current scope
8383 --> $DIR/issue-2392.rs:55:12
8484 |
8585LL | struct Obj<F> where F: FnOnce() -> u32 {
......@@ -90,7 +90,7 @@ LL | w.wrap.not_closure();
9090 | |
9191 | field, not a method
9292
93error[E0599]: no method named `closure` found for struct `Obj` in the current scope
93error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
9494 --> $DIR/issue-2392.rs:58:24
9595 |
9696LL | struct Obj<F> where F: FnOnce() -> u32 {
tests/ui/consts/issue-19244-1.stderr+2
......@@ -3,6 +3,8 @@ error[E0609]: no field `1` on type `(usize,)`
33 |
44LL | let a: [isize; TUP.1];
55 | ^ unknown field
6 |
7 = note: available field is: `0`
68
79error: aborting due to 1 previous error
810
tests/ui/custom_test_frameworks/mismatch.stderr+1-1
......@@ -2,7 +2,7 @@ error[E0277]: the trait bound `TestDescAndFn: Testable` is not satisfied
22 --> $DIR/mismatch.rs:9:1
33 |
44LL | #[test]
5 | ------- in this procedural macro expansion
5 | ------- in this attribute macro expansion
66LL | fn wrong_kind(){}
77 | ^^^^^^^^^^^^^^^^^ the trait `Testable` is not implemented for `TestDescAndFn`
88 |
tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr+1-1
......@@ -43,7 +43,7 @@ help: consider introducing lifetime `'a` here
4343LL | impl<'a> Trait for Z {
4444 | ++++
4545
46error[E0599]: no function or associated item named `new` found for struct `InvariantRef` in the current scope
46error[E0599]: no function or associated item named `new` found for struct `InvariantRef<'a, T>` in the current scope
4747 --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:9:41
4848 |
4949LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
tests/ui/diagnostic-width/long-E0609.stderr+1
......@@ -4,6 +4,7 @@ error[E0609]: no field `field` on type `(..., ..., ..., ...)`
44LL | x.field;
55 | ^^^^^ unknown field
66 |
7 = note: available fields are: `0`, `1`, `2`, `3`
78 = note: the full name for the type has been written to '$TEST_BUILD_DIR/long-E0609.long-type-$LONG_TYPE_HASH.txt'
89 = note: consider using `--verbose` to print the full type name to the console
910
tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs+1
......@@ -1,5 +1,6 @@
11// Issue 22443: Reject code using non-regular types that would
22// otherwise cause dropck to loop infinitely.
3//@ compile-flags: -Zwrite-long-types-to-disk=yes
34
45use std::marker::PhantomData;
56
tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr+4-2
......@@ -1,10 +1,12 @@
11error[E0320]: overflow while adding drop-check rules for `FingerTree<i32>`
2 --> $DIR/dropck_no_diverge_on_nonregular_1.rs:24:9
2 --> $DIR/dropck_no_diverge_on_nonregular_1.rs:25:9
33 |
44LL | let ft =
55 | ^^
66 |
7 = note: overflowed on `FingerTree<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<i32>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
7 = note: overflowed on `FingerTree<Node<Node<Node<Node<Node<Node<Node<Node<Node<...>>>>>>>>>>`
8 = note: the full name for the type has been written to '$TEST_BUILD_DIR/dropck_no_diverge_on_nonregular_1.long-type-$LONG_TYPE_HASH.txt'
9 = note: consider using `--verbose` to print the full type name to the console
810
911error: aborting due to 1 previous error
1012
tests/ui/editions/never-type-fallback-breaking.e2024.stderr+4-4
......@@ -5,7 +5,7 @@ LL | true => Default::default(),
55 | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!`
66 |
77 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
8 = help: did you intend to use the type `()` here instead?
8 = help: you might have intended to use the type `()` here instead
99
1010error[E0277]: the trait bound `!: Default` is not satisfied
1111 --> $DIR/never-type-fallback-breaking.rs:37:5
......@@ -14,7 +14,7 @@ LL | deserialize()?;
1414 | ^^^^^^^^^^^^^ the trait `Default` is not implemented for `!`
1515 |
1616 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
17 = help: did you intend to use the type `()` here instead?
17 = help: you might have intended to use the type `()` here instead
1818note: required by a bound in `deserialize`
1919 --> $DIR/never-type-fallback-breaking.rs:33:23
2020 |
......@@ -51,7 +51,7 @@ LL | takes_apit(|| Default::default())?;
5151 | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!`
5252 |
5353 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
54 = help: did you intend to use the type `()` here instead?
54 = help: you might have intended to use the type `()` here instead
5555
5656error[E0277]: the trait bound `!: Default` is not satisfied
5757 --> $DIR/never-type-fallback-breaking.rs:76:17
......@@ -62,7 +62,7 @@ LL | takes_apit2(mk()?);
6262 | required by a bound introduced by this call
6363 |
6464 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
65 = help: did you intend to use the type `()` here instead?
65 = help: you might have intended to use the type `()` here instead
6666note: required by a bound in `takes_apit2`
6767 --> $DIR/never-type-fallback-breaking.rs:71:25
6868 |
tests/ui/error-codes/E0275.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12trait Foo {}
23
34struct Bar<T>(T);
tests/ui/error-codes/E0275.stderr+5-3
......@@ -1,17 +1,19 @@
11error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>: Foo`
2 --> $DIR/E0275.rs:5:33
2 --> $DIR/E0275.rs:6:33
33 |
44LL | impl<T> Foo for T where Bar<T>: Foo {}
55 | ^^^
66 |
77 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`)
8note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo`
9 --> $DIR/E0275.rs:5:9
8note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>>>>>>>` to implement `Foo`
9 --> $DIR/E0275.rs:6:9
1010 |
1111LL | impl<T> Foo for T where Bar<T>: Foo {}
1212 | ^^^ ^ --- unsatisfied trait bound introduced here
1313 = note: 126 redundant requirements hidden
1414 = note: required for `Bar<T>` to implement `Foo`
15 = note: the full name for the type has been written to '$TEST_BUILD_DIR/E0275.long-type-$LONG_TYPE_HASH.txt'
16 = note: consider using `--verbose` to print the full type name to the console
1517
1618error: aborting due to 1 previous error
1719
tests/ui/error-codes/ex-E0612.stderr+1-5
......@@ -4,11 +4,7 @@ error[E0609]: no field `1` on type `Foo`
44LL | y.1;
55 | ^ unknown field
66 |
7help: a field with a similar name exists
8 |
9LL - y.1;
10LL + y.0;
11 |
7 = note: available field is: `0`
128
139error: aborting due to 1 previous error
1410
tests/ui/feature-gates/feature-gate-macro-attr.rs created+4
......@@ -0,0 +1,4 @@
1#![crate_type = "lib"]
2
3macro_rules! myattr { attr() {} => {} }
4//~^ ERROR `macro_rules!` attributes are unstable
tests/ui/feature-gates/feature-gate-macro-attr.stderr created+13
......@@ -0,0 +1,13 @@
1error[E0658]: `macro_rules!` attributes are unstable
2 --> $DIR/feature-gate-macro-attr.rs:3:1
3 |
4LL | macro_rules! myattr { attr() {} => {} }
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 |
7 = note: see issue #83527 <https://github.com/rust-lang/rust/issues/83527> for more information
8 = help: add `#![feature(macro_attr)]` to the crate attributes to enable
9 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
11error: aborting due to 1 previous error
12
13For more information about this error, try `rustc --explain E0658`.
tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs+2
......@@ -6,6 +6,8 @@
66// This tests double-checks that we do not allow such behavior to leak
77// through again.
88
9//@ compile-flags: -Zwrite-long-types-to-disk=yes
10
911pub trait Stream {
1012 type Item;
1113 fn next(self) -> Option<Self::Item>;
tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr+9-7
......@@ -1,5 +1,5 @@
1error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>`, but its trait bounds were not satisfied
2 --> $DIR/hrtb-doesnt-borrow-self-2.rs:110:24
1error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, {closure@...}>`, but its trait bounds were not satisfied
2 --> $DIR/hrtb-doesnt-borrow-self-2.rs:112:24
33 |
44LL | pub struct Filter<S, F> {
55 | ----------------------- method `countx` not found for this struct because it doesn't satisfy `_: StreamExt`
......@@ -8,19 +8,21 @@ LL | let count = filter.countx();
88 | ^^^^^^ method cannot be called due to unsatisfied trait bounds
99 |
1010note: the following trait bounds were not satisfied:
11 `&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream`
12 `&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream`
13 `&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream`
14 --> $DIR/hrtb-doesnt-borrow-self-2.rs:96:50
11 `&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream`
12 `&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream`
13 `&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream`
14 --> $DIR/hrtb-doesnt-borrow-self-2.rs:98:50
1515 |
1616LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
1717 | --------- - ^^^^^^ unsatisfied trait bound introduced here
1818 = help: items from traits can only be used if the trait is implemented and in scope
1919note: `StreamExt` defines an item `countx`, perhaps you need to implement it
20 --> $DIR/hrtb-doesnt-borrow-self-2.rs:64:1
20 --> $DIR/hrtb-doesnt-borrow-self-2.rs:66:1
2121 |
2222LL | pub trait StreamExt
2323 | ^^^^^^^^^^^^^^^^^^^
24 = note: the full name for the type has been written to '$TEST_BUILD_DIR/hrtb-doesnt-borrow-self-2.long-type-$LONG_TYPE_HASH.txt'
25 = note: consider using `--verbose` to print the full type name to the console
2426
2527error: aborting due to 1 previous error
2628
tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12use std::cell::Cell;
23use std::rc::Rc;
34
tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr+8-8
......@@ -1,5 +1,5 @@
11error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely
2 --> $DIR/auto-trait-leak2.rs:20:10
2 --> $DIR/auto-trait-leak2.rs:21:10
33 |
44LL | fn before() -> impl Fn(i32) {
55 | ------------ within this `impl Fn(i32)`
......@@ -11,23 +11,23 @@ LL | send(before());
1111 |
1212 = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>`
1313note: required because it's used within this closure
14 --> $DIR/auto-trait-leak2.rs:10:5
14 --> $DIR/auto-trait-leak2.rs:11:5
1515 |
1616LL | move |x| p.set(x)
1717 | ^^^^^^^^
1818note: required because it appears within the type `impl Fn(i32)`
19 --> $DIR/auto-trait-leak2.rs:5:16
19 --> $DIR/auto-trait-leak2.rs:6:16
2020 |
2121LL | fn before() -> impl Fn(i32) {
2222 | ^^^^^^^^^^^^
2323note: required by a bound in `send`
24 --> $DIR/auto-trait-leak2.rs:13:12
24 --> $DIR/auto-trait-leak2.rs:14:12
2525 |
2626LL | fn send<T: Send>(_: T) {}
2727 | ^^^^ required by this bound in `send`
2828
2929error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely
30 --> $DIR/auto-trait-leak2.rs:25:10
30 --> $DIR/auto-trait-leak2.rs:26:10
3131 |
3232LL | send(after());
3333 | ---- ^^^^^^^ `Rc<Cell<i32>>` cannot be sent between threads safely
......@@ -39,17 +39,17 @@ LL | fn after() -> impl Fn(i32) {
3939 |
4040 = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>`
4141note: required because it's used within this closure
42 --> $DIR/auto-trait-leak2.rs:38:5
42 --> $DIR/auto-trait-leak2.rs:39:5
4343 |
4444LL | move |x| p.set(x)
4545 | ^^^^^^^^
4646note: required because it appears within the type `impl Fn(i32)`
47 --> $DIR/auto-trait-leak2.rs:33:15
47 --> $DIR/auto-trait-leak2.rs:34:15
4848 |
4949LL | fn after() -> impl Fn(i32) {
5050 | ^^^^^^^^^^^^
5151note: required by a bound in `send`
52 --> $DIR/auto-trait-leak2.rs:13:12
52 --> $DIR/auto-trait-leak2.rs:14:12
5353 |
5454LL | fn send<T: Send>(_: T) {}
5555 | ^^^^ required by this bound in `send`
tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12type A = (i32, i32, i32, i32);
23type B = (A, A, A, A);
34type C = (B, B, B, B);
tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr+4-2
......@@ -1,9 +1,11 @@
1error[E0282]: type annotations needed for `Result<_, ((((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))))>`
2 --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:7:9
1error[E0282]: type annotations needed for `Result<_, (((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)>`
2 --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:8:9
33 |
44LL | let y = Err(x);
55 | ^ ------ type must be known at this point
66 |
7 = note: the full name for the type has been written to '$TEST_BUILD_DIR/really-long-type-in-let-binding-without-sufficient-type-info.long-type-$LONG_TYPE_HASH.txt'
8 = note: consider using `--verbose` to print the full type name to the console
79help: consider giving `y` an explicit type, where the type for type parameter `T` is specified
810 |
911LL | let y: Result<T, _> = Err(x);
tests/ui/interior-mutability/interior-mutability.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12use std::cell::Cell;
23use std::panic::catch_unwind;
34fn main() {
tests/ui/interior-mutability/interior-mutability.stderr+2-2
......@@ -1,5 +1,5 @@
11error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
2 --> $DIR/interior-mutability.rs:5:18
2 --> $DIR/interior-mutability.rs:6:18
33 |
44LL | catch_unwind(|| { x.set(23); });
55 | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
......@@ -11,7 +11,7 @@ note: required because it appears within the type `Cell<i32>`
1111 --> $SRC_DIR/core/src/cell.rs:LL:COL
1212 = note: required for `&Cell<i32>` to implement `UnwindSafe`
1313note: required because it's used within this closure
14 --> $DIR/interior-mutability.rs:5:18
14 --> $DIR/interior-mutability.rs:6:18
1515 |
1616LL | catch_unwind(|| { x.set(23); });
1717 | ^^
tests/ui/intrinsics/intrinsic-atomics.rs+6-6
......@@ -33,14 +33,14 @@ pub fn main() {
3333 assert_eq!(rusti::atomic_xchg::<_, { Release }>(&mut *x, 0), 1);
3434 assert_eq!(*x, 0);
3535
36 assert_eq!(rusti::atomic_xadd::<_, { SeqCst }>(&mut *x, 1), 0);
37 assert_eq!(rusti::atomic_xadd::<_, { Acquire }>(&mut *x, 1), 1);
38 assert_eq!(rusti::atomic_xadd::<_, { Release }>(&mut *x, 1), 2);
36 assert_eq!(rusti::atomic_xadd::<_, _, { SeqCst }>(&mut *x, 1), 0);
37 assert_eq!(rusti::atomic_xadd::<_, _, { Acquire }>(&mut *x, 1), 1);
38 assert_eq!(rusti::atomic_xadd::<_, _, { Release }>(&mut *x, 1), 2);
3939 assert_eq!(*x, 3);
4040
41 assert_eq!(rusti::atomic_xsub::<_, { SeqCst }>(&mut *x, 1), 3);
42 assert_eq!(rusti::atomic_xsub::<_, { Acquire }>(&mut *x, 1), 2);
43 assert_eq!(rusti::atomic_xsub::<_, { Release }>(&mut *x, 1), 1);
41 assert_eq!(rusti::atomic_xsub::<_, _, { SeqCst }>(&mut *x, 1), 3);
42 assert_eq!(rusti::atomic_xsub::<_, _, { Acquire }>(&mut *x, 1), 2);
43 assert_eq!(rusti::atomic_xsub::<_, _, { Release }>(&mut *x, 1), 1);
4444 assert_eq!(*x, 0);
4545
4646 loop {
tests/ui/intrinsics/non-integer-atomic.rs+16-16
......@@ -13,80 +13,80 @@ pub type Quux = [u8; 100];
1313
1414pub unsafe fn test_bool_load(p: &mut bool, v: bool) {
1515 intrinsics::atomic_load::<_, { SeqCst }>(p);
16 //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool`
16 //~^ ERROR `atomic_load` intrinsic: expected basic integer or pointer type, found `bool`
1717}
1818
1919pub unsafe fn test_bool_store(p: &mut bool, v: bool) {
2020 intrinsics::atomic_store::<_, { SeqCst }>(p, v);
21 //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool`
21 //~^ ERROR `atomic_store` intrinsic: expected basic integer or pointer type, found `bool`
2222}
2323
2424pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) {
2525 intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
26 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool`
26 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer or pointer type, found `bool`
2727}
2828
2929pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) {
3030 intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
31 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool`
31 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `bool`
3232}
3333
3434pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) {
3535 intrinsics::atomic_load::<_, { SeqCst }>(p);
36 //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo`
36 //~^ ERROR `atomic_load` intrinsic: expected basic integer or pointer type, found `Foo`
3737}
3838
3939pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) {
4040 intrinsics::atomic_store::<_, { SeqCst }>(p, v);
41 //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo`
41 //~^ ERROR `atomic_store` intrinsic: expected basic integer or pointer type, found `Foo`
4242}
4343
4444pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) {
4545 intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
46 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo`
46 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer or pointer type, found `Foo`
4747}
4848
4949pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) {
5050 intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
51 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo`
51 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `Foo`
5252}
5353
5454pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) {
5555 intrinsics::atomic_load::<_, { SeqCst }>(p);
56 //~^ ERROR expected basic integer type, found `&dyn Fn()`
56 //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()`
5757}
5858
5959pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) {
6060 intrinsics::atomic_store::<_, { SeqCst }>(p, v);
61 //~^ ERROR expected basic integer type, found `&dyn Fn()`
61 //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()`
6262}
6363
6464pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) {
6565 intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
66 //~^ ERROR expected basic integer type, found `&dyn Fn()`
66 //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()`
6767}
6868
6969pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) {
7070 intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
71 //~^ ERROR expected basic integer type, found `&dyn Fn()`
71 //~^ ERROR expected basic integer or pointer type, found `&dyn Fn()`
7272}
7373
7474pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) {
7575 intrinsics::atomic_load::<_, { SeqCst }>(p);
76 //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]`
76 //~^ ERROR `atomic_load` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
7777}
7878
7979pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) {
8080 intrinsics::atomic_store::<_, { SeqCst }>(p, v);
81 //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]`
81 //~^ ERROR `atomic_store` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
8282}
8383
8484pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) {
8585 intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
86 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]`
86 //~^ ERROR `atomic_xchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
8787}
8888
8989pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) {
9090 intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
91 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]`
91 //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
9292}
tests/ui/intrinsics/non-integer-atomic.stderr+16-16
......@@ -1,94 +1,94 @@
1error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `bool`
1error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `bool`
22 --> $DIR/non-integer-atomic.rs:15:5
33 |
44LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
7error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `bool`
7error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `bool`
88 --> $DIR/non-integer-atomic.rs:20:5
99 |
1010LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
1111 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
13error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `bool`
13error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `bool`
1414 --> $DIR/non-integer-atomic.rs:25:5
1515 |
1616LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
1717 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818
19error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `bool`
19error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `bool`
2020 --> $DIR/non-integer-atomic.rs:30:5
2121 |
2222LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
2323 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424
25error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `Foo`
25error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `Foo`
2626 --> $DIR/non-integer-atomic.rs:35:5
2727 |
2828LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
2929 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030
31error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `Foo`
31error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `Foo`
3232 --> $DIR/non-integer-atomic.rs:40:5
3333 |
3434LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
3535 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636
37error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `Foo`
37error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `Foo`
3838 --> $DIR/non-integer-atomic.rs:45:5
3939 |
4040LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
4141 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4242
43error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `Foo`
43error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `Foo`
4444 --> $DIR/non-integer-atomic.rs:50:5
4545 |
4646LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
4747 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4848
49error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `&dyn Fn()`
49error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
5050 --> $DIR/non-integer-atomic.rs:55:5
5151 |
5252LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
5353 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5454
55error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `&dyn Fn()`
55error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
5656 --> $DIR/non-integer-atomic.rs:60:5
5757 |
5858LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
5959 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6060
61error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `&dyn Fn()`
61error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
6262 --> $DIR/non-integer-atomic.rs:65:5
6363 |
6464LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
6565 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6666
67error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `&dyn Fn()`
67error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `&dyn Fn()`
6868 --> $DIR/non-integer-atomic.rs:70:5
6969 |
7070LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
7171 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7272
73error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]`
73error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
7474 --> $DIR/non-integer-atomic.rs:75:5
7575 |
7676LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
7777 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7878
79error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]`
79error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
8080 --> $DIR/non-integer-atomic.rs:80:5
8181 |
8282LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
8383 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8484
85error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]`
85error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
8686 --> $DIR/non-integer-atomic.rs:85:5
8787 |
8888LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
8989 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9090
91error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]`
91error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer or pointer type, found `[u8; 100]`
9292 --> $DIR/non-integer-atomic.rs:90:5
9393 |
9494LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
tests/ui/issues/issue-41880.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `iter` found for struct `Iterate` in the current scope
1error[E0599]: no method named `iter` found for struct `Iterate<T, F>` in the current scope
22 --> $DIR/issue-41880.rs:27:24
33 |
44LL | pub struct Iterate<T, F> {
tests/ui/macros/macro-rules-as-derive-or-attr-issue-132928.stderr+1-1
......@@ -11,7 +11,7 @@ error: cannot find attribute `sample` in this scope
1111 --> $DIR/macro-rules-as-derive-or-attr-issue-132928.rs:5:3
1212 |
1313LL | macro_rules! sample { () => {} }
14 | ------ `sample` exists, but a declarative macro cannot be used as an attribute macro
14 | ------ `sample` exists, but has no `attr` rules
1515LL |
1616LL | #[sample]
1717 | ^^^^^^
tests/ui/macros/macro-rules-attr-error.rs created+15
......@@ -0,0 +1,15 @@
1#![feature(macro_attr)]
2
3macro_rules! local_attr {
4 attr() { $($body:tt)* } => {
5 compile_error!(concat!("local_attr: ", stringify!($($body)*)));
6 };
7 //~^^ ERROR: local_attr
8}
9
10fn main() {
11 #[local_attr]
12 struct S;
13
14 local_attr!(arg); //~ ERROR: macro has no rules for function-like invocation
15}
tests/ui/macros/macro-rules-attr-error.stderr created+22
......@@ -0,0 +1,22 @@
1error: local_attr: struct S;
2 --> $DIR/macro-rules-attr-error.rs:5:9
3 |
4LL | compile_error!(concat!("local_attr: ", stringify!($($body)*)));
5 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6...
7LL | #[local_attr]
8 | ------------- in this attribute macro expansion
9 |
10 = note: this error originates in the attribute macro `local_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
11
12error: macro has no rules for function-like invocation `local_attr!`
13 --> $DIR/macro-rules-attr-error.rs:14:5
14 |
15LL | macro_rules! local_attr {
16 | ----------------------- this macro has no rules for function-like invocation
17...
18LL | local_attr!(arg);
19 | ^^^^^^^^^^^^^^^^
20
21error: aborting due to 2 previous errors
22
tests/ui/macros/macro-rules-attr-infinite-recursion.rs created+12
......@@ -0,0 +1,12 @@
1#![crate_type = "lib"]
2#![feature(macro_attr)]
3
4macro_rules! attr {
5 attr() { $($body:tt)* } => {
6 #[attr] $($body)*
7 };
8 //~^^ ERROR: recursion limit reached
9}
10
11#[attr]
12struct S;
tests/ui/macros/macro-rules-attr-infinite-recursion.stderr created+14
......@@ -0,0 +1,14 @@
1error: recursion limit reached while expanding `#[attr]`
2 --> $DIR/macro-rules-attr-infinite-recursion.rs:6:9
3 |
4LL | #[attr] $($body)*
5 | ^^^^^^^
6...
7LL | #[attr]
8 | ------- in this attribute macro expansion
9 |
10 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`macro_rules_attr_infinite_recursion`)
11 = note: this error originates in the attribute macro `attr` (in Nightly builds, run with -Z macro-backtrace for more info)
12
13error: aborting due to 1 previous error
14
tests/ui/macros/macro-rules-attr-nested.rs created+24
......@@ -0,0 +1,24 @@
1//@ run-pass
2//@ check-run-results
3#![feature(macro_attr)]
4
5macro_rules! nest {
6 attr() { struct $name:ident; } => {
7 println!("nest");
8 #[nest(1)]
9 struct $name;
10 };
11 attr(1) { struct $name:ident; } => {
12 println!("nest(1)");
13 #[nest(2)]
14 struct $name;
15 };
16 attr(2) { struct $name:ident; } => {
17 println!("nest(2)");
18 };
19}
20
21fn main() {
22 #[nest]
23 struct S;
24}
tests/ui/macros/macro-rules-attr-nested.run.stdout created+3
......@@ -0,0 +1,3 @@
1nest
2nest(1)
3nest(2)
tests/ui/macros/macro-rules-attr.rs created+90
......@@ -0,0 +1,90 @@
1//@ run-pass
2//@ check-run-results
3#![feature(macro_attr)]
4#![warn(unused)]
5
6#[macro_export]
7macro_rules! exported_attr {
8 attr($($args:tt)*) { $($body:tt)* } => {
9 println!(
10 "exported_attr: args={:?}, body={:?}",
11 stringify!($($args)*),
12 stringify!($($body)*),
13 );
14 };
15 { $($args:tt)* } => {
16 println!("exported_attr!({:?})", stringify!($($args)*));
17 };
18 attr() {} => {
19 unused_rule();
20 };
21 attr() {} => {
22 compile_error!();
23 };
24 {} => {
25 unused_rule();
26 };
27 {} => {
28 compile_error!();
29 };
30}
31
32macro_rules! local_attr {
33 attr($($args:tt)*) { $($body:tt)* } => {
34 println!(
35 "local_attr: args={:?}, body={:?}",
36 stringify!($($args)*),
37 stringify!($($body)*),
38 );
39 };
40 { $($args:tt)* } => {
41 println!("local_attr!({:?})", stringify!($($args)*));
42 };
43 attr() {} => { //~ WARN: never used
44 unused_rule();
45 };
46 attr() {} => {
47 compile_error!();
48 };
49 {} => { //~ WARN: never used
50 unused_rule();
51 };
52 {} => {
53 compile_error!();
54 };
55}
56
57fn main() {
58 #[crate::exported_attr]
59 struct S;
60 #[::exported_attr(arguments, key = "value")]
61 fn func(_arg: u32) {}
62 #[self::exported_attr(1)]
63 #[self::exported_attr(2)]
64 struct Twice;
65
66 crate::exported_attr!();
67 crate::exported_attr!(invoked, arguments);
68
69 #[exported_attr]
70 struct S;
71 #[exported_attr(arguments, key = "value")]
72 fn func(_arg: u32) {}
73 #[exported_attr(1)]
74 #[exported_attr(2)]
75 struct Twice;
76
77 exported_attr!();
78 exported_attr!(invoked, arguments);
79
80 #[local_attr]
81 struct S;
82 #[local_attr(arguments, key = "value")]
83 fn func(_arg: u32) {}
84 #[local_attr(1)]
85 #[local_attr(2)]
86 struct Twice;
87
88 local_attr!();
89 local_attr!(invoked, arguments);
90}
tests/ui/macros/macro-rules-attr.run.stdout created+15
......@@ -0,0 +1,15 @@
1exported_attr: args="", body="struct S;"
2exported_attr: args="arguments, key = \"value\"", body="fn func(_arg: u32) {}"
3exported_attr: args="1", body="#[self::exported_attr(2)] struct Twice;"
4exported_attr!("")
5exported_attr!("invoked, arguments")
6exported_attr: args="", body="struct S;"
7exported_attr: args="arguments, key = \"value\"", body="fn func(_arg: u32) {}"
8exported_attr: args="1", body="#[exported_attr(2)] struct Twice;"
9exported_attr!("")
10exported_attr!("invoked, arguments")
11local_attr: args="", body="struct S;"
12local_attr: args="arguments, key = \"value\"", body="fn func(_arg: u32) {}"
13local_attr: args="1", body="#[local_attr(2)] struct Twice;"
14local_attr!("")
15local_attr!("invoked, arguments")
tests/ui/macros/macro-rules-attr.stderr created+21
......@@ -0,0 +1,21 @@
1warning: rule #3 of macro `local_attr` is never used
2 --> $DIR/macro-rules-attr.rs:43:9
3 |
4LL | attr() {} => {
5 | ^^ ^^
6 |
7note: the lint level is defined here
8 --> $DIR/macro-rules-attr.rs:4:9
9 |
10LL | #![warn(unused)]
11 | ^^^^^^
12 = note: `#[warn(unused_macro_rules)]` implied by `#[warn(unused)]`
13
14warning: rule #5 of macro `local_attr` is never used
15 --> $DIR/macro-rules-attr.rs:49:5
16 |
17LL | {} => {
18 | ^^
19
20warning: 2 warnings emitted
21
tests/ui/methods/call_method_unknown_referent.rs+1-1
......@@ -44,5 +44,5 @@ fn main() {
4444 // our resolution logic needs to be able to call methods such as foo()
4545 // on the outer type even if the inner type is ambiguous.
4646 let _c = (ptr as SmartPtr<_>).read();
47 //~^ ERROR no method named `read` found for struct `SmartPtr`
47 //~^ ERROR no method named `read` found for struct `SmartPtr<T>`
4848}
tests/ui/methods/call_method_unknown_referent.stderr+1-1
......@@ -10,7 +10,7 @@ error[E0282]: type annotations needed
1010LL | let _b = (rc as std::rc::Rc<_>).read();
1111 | ^^^^ cannot infer type
1212
13error[E0599]: no method named `read` found for struct `SmartPtr` in the current scope
13error[E0599]: no method named `read` found for struct `SmartPtr<T>` in the current scope
1414 --> $DIR/call_method_unknown_referent.rs:46:35
1515 |
1616LL | struct SmartPtr<T>(T);
tests/ui/methods/inherent-bound-in-probe.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12// Fixes #110131
23//
34// The issue is that we were constructing an `ImplDerived` cause code for the
tests/ui/methods/inherent-bound-in-probe.stderr+7-5
......@@ -1,5 +1,5 @@
11error[E0277]: `Helper<'a, T>` is not an iterator
2 --> $DIR/inherent-bound-in-probe.rs:38:21
2 --> $DIR/inherent-bound-in-probe.rs:39:21
33 |
44LL | type IntoIter = Helper<'a, T>;
55 | ^^^^^^^^^^^^^ `Helper<'a, T>` is not an iterator
......@@ -9,14 +9,14 @@ note: required by a bound in `std::iter::IntoIterator::IntoIter`
99 --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
1010
1111error[E0275]: overflow evaluating the requirement `&_: IntoIterator`
12 --> $DIR/inherent-bound-in-probe.rs:42:9
12 --> $DIR/inherent-bound-in-probe.rs:43:9
1313 |
1414LL | Helper::new(&self.0)
1515 | ^^^^^^
1616 |
1717 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_bound_in_probe`)
1818note: required for `&BitReaderWrapper<_>` to implement `IntoIterator`
19 --> $DIR/inherent-bound-in-probe.rs:32:13
19 --> $DIR/inherent-bound-in-probe.rs:33:13
2020 |
2121LL | impl<'a, T> IntoIterator for &'a BitReaderWrapper<T>
2222 | ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
......@@ -24,15 +24,17 @@ LL | where
2424LL | &'a T: IntoIterator<Item = &'a u8>,
2525 | ------------- unsatisfied trait bound introduced here
2626 = note: 126 redundant requirements hidden
27 = note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<_>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `IntoIterator`
27 = note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<...>>>` to implement `IntoIterator`
2828note: required by a bound in `Helper`
29 --> $DIR/inherent-bound-in-probe.rs:16:12
29 --> $DIR/inherent-bound-in-probe.rs:17:12
3030 |
3131LL | struct Helper<'a, T>
3232 | ------ required by a bound in this struct
3333LL | where
3434LL | &'a T: IntoIterator<Item = &'a u8>,
3535 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Helper`
36 = note: the full name for the type has been written to '$TEST_BUILD_DIR/inherent-bound-in-probe.long-type-$LONG_TYPE_HASH.txt'
37 = note: consider using `--verbose` to print the full type name to the console
3638
3739error: aborting due to 2 previous errors
3840
tests/ui/methods/method-not-found-generic-arg-elision.stderr+4-4
......@@ -10,7 +10,7 @@ LL | let d = point_i32.distance();
1010 = note: the method was found for
1111 - `Point<f64>`
1212
13error[E0599]: no method named `other` found for struct `Point` in the current scope
13error[E0599]: no method named `other` found for struct `Point<T>` in the current scope
1414 --> $DIR/method-not-found-generic-arg-elision.rs:84:23
1515 |
1616LL | struct Point<T> {
......@@ -19,7 +19,7 @@ LL | struct Point<T> {
1919LL | let d = point_i32.other();
2020 | ^^^^^ method not found in `Point<i32>`
2121
22error[E0599]: no method named `extend` found for struct `Map` in the current scope
22error[E0599]: no method named `extend` found for struct `Map<I, F>` in the current scope
2323 --> $DIR/method-not-found-generic-arg-elision.rs:87:67
2424 |
2525LL | v.iter().map(Box::new(|x| x * x) as Box<dyn Fn(&i32) -> i32>).extend(std::iter::once(100));
......@@ -41,7 +41,7 @@ LL | wrapper.method();
4141 - `Wrapper<i8>`
4242 and 2 more types
4343
44error[E0599]: no method named `other` found for struct `Wrapper` in the current scope
44error[E0599]: no method named `other` found for struct `Wrapper<T>` in the current scope
4545 --> $DIR/method-not-found-generic-arg-elision.rs:92:13
4646 |
4747LL | struct Wrapper<T>(T);
......@@ -64,7 +64,7 @@ LL | wrapper.method();
6464 - `Wrapper2<'a, i32, C>`
6565 - `Wrapper2<'a, i8, C>`
6666
67error[E0599]: no method named `other` found for struct `Wrapper2` in the current scope
67error[E0599]: no method named `other` found for struct `Wrapper2<'a, T, C>` in the current scope
6868 --> $DIR/method-not-found-generic-arg-elision.rs:98:13
6969 |
7070LL | struct Wrapper2<'a, T, const C: usize> {
tests/ui/methods/probe-error-on-infinite-deref.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12use std::ops::Deref;
23
34// Make sure that method probe error reporting doesn't get too tangled up
tests/ui/methods/probe-error-on-infinite-deref.stderr+5-3
......@@ -1,13 +1,15 @@
1error[E0055]: reached the recursion limit while auto-dereferencing `Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<{integer}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
2 --> $DIR/probe-error-on-infinite-deref.rs:13:13
1error[E0055]: reached the recursion limit while auto-dereferencing `Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<...>>>>>>>>>>>`
2 --> $DIR/probe-error-on-infinite-deref.rs:14:13
33 |
44LL | Wrap(1).lmao();
55 | ^^^^ deref recursion limit reached
66 |
77 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`probe_error_on_infinite_deref`)
8 = note: the full name for the type has been written to '$TEST_BUILD_DIR/probe-error-on-infinite-deref.long-type-$LONG_TYPE_HASH.txt'
9 = note: consider using `--verbose` to print the full type name to the console
810
911error[E0599]: no method named `lmao` found for struct `Wrap<{integer}>` in the current scope
10 --> $DIR/probe-error-on-infinite-deref.rs:13:13
12 --> $DIR/probe-error-on-infinite-deref.rs:14:13
1113 |
1214LL | struct Wrap<T>(T);
1315 | -------------- method `lmao` not found for this struct
tests/ui/methods/untrimmed-path-type.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `unknown` found for enum `Result` in the current scope
1error[E0599]: no method named `unknown` found for enum `Result<T, E>` in the current scope
22 --> $DIR/untrimmed-path-type.rs:5:11
33 |
44LL | meow().unknown();
tests/ui/never_type/defaulted-never-note.fallback.stderr+1-1
......@@ -8,7 +8,7 @@ LL | foo(_x);
88 |
99 = help: the trait `ImplementedForUnitButNotNever` is implemented for `()`
1010 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
11 = help: did you intend to use the type `()` here instead?
11 = help: you might have intended to use the type `()` here instead
1212note: required by a bound in `foo`
1313 --> $DIR/defaulted-never-note.rs:25:11
1414 |
tests/ui/never_type/defaulted-never-note.rs+1-1
......@@ -35,7 +35,7 @@ fn smeg() {
3535 //[fallback]~| HELP trait `ImplementedForUnitButNotNever` is implemented for `()`
3636 //[fallback]~| NOTE this error might have been caused
3737 //[fallback]~| NOTE required by a bound introduced by this call
38 //[fallback]~| HELP did you intend
38 //[fallback]~| HELP you might have intended to use the type `()`
3939}
4040
4141fn main() {
tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr+1-1
......@@ -10,7 +10,7 @@ LL | unconstrained_arg(return);
1010 ()
1111 i32
1212 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
13 = help: did you intend to use the type `()` here instead?
13 = help: you might have intended to use the type `()` here instead
1414note: required by a bound in `unconstrained_arg`
1515 --> $DIR/diverging-fallback-no-leak.rs:12:25
1616 |
tests/ui/offset-of/offset-of-tuple-field.stderr+36
......@@ -15,60 +15,96 @@ error[E0609]: no field `_0` on type `(u8, u8)`
1515 |
1616LL | offset_of!((u8, u8), _0);
1717 | ^^
18 |
19help: a field with a similar name exists
20 |
21LL - offset_of!((u8, u8), _0);
22LL + offset_of!((u8, u8), 0);
23 |
1824
1925error[E0609]: no field `01` on type `(u8, u8)`
2026 --> $DIR/offset-of-tuple-field.rs:7:26
2127 |
2228LL | offset_of!((u8, u8), 01);
2329 | ^^
30 |
31 = note: available fields are: `0`, `1`
2432
2533error[E0609]: no field `1e2` on type `(u8, u8)`
2634 --> $DIR/offset-of-tuple-field.rs:8:26
2735 |
2836LL | offset_of!((u8, u8), 1e2);
2937 | ^^^
38 |
39 = note: available fields are: `0`, `1`
3040
3141error[E0609]: no field `1_` on type `(u8, u8)`
3242 --> $DIR/offset-of-tuple-field.rs:9:26
3343 |
3444LL | offset_of!((u8, u8), 1_u8);
3545 | ^^^^
46 |
47help: a field with a similar name exists
48 |
49LL - offset_of!((u8, u8), 1_u8);
50LL + offset_of!((u8, u8), 1);
51 |
3652
3753error[E0609]: no field `1e2` on type `(u8, u8)`
3854 --> $DIR/offset-of-tuple-field.rs:12:35
3955 |
4056LL | builtin # offset_of((u8, u8), 1e2);
4157 | ^^^
58 |
59 = note: available fields are: `0`, `1`
4260
4361error[E0609]: no field `_0` on type `(u8, u8)`
4462 --> $DIR/offset-of-tuple-field.rs:13:35
4563 |
4664LL | builtin # offset_of((u8, u8), _0);
4765 | ^^
66 |
67help: a field with a similar name exists
68 |
69LL - builtin # offset_of((u8, u8), _0);
70LL + builtin # offset_of((u8, u8), 0);
71 |
4872
4973error[E0609]: no field `01` on type `(u8, u8)`
5074 --> $DIR/offset-of-tuple-field.rs:14:35
5175 |
5276LL | builtin # offset_of((u8, u8), 01);
5377 | ^^
78 |
79 = note: available fields are: `0`, `1`
5480
5581error[E0609]: no field `1_` on type `(u8, u8)`
5682 --> $DIR/offset-of-tuple-field.rs:15:35
5783 |
5884LL | builtin # offset_of((u8, u8), 1_u8);
5985 | ^^^^
86 |
87help: a field with a similar name exists
88 |
89LL - builtin # offset_of((u8, u8), 1_u8);
90LL + builtin # offset_of((u8, u8), 1);
91 |
6092
6193error[E0609]: no field `2` on type `(u8, u16)`
6294 --> $DIR/offset-of-tuple-field.rs:18:47
6395 |
6496LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.2);
6597 | ^
98 |
99 = note: available fields are: `0`, `1`
66100
67101error[E0609]: no field `1e2` on type `(u8, u16)`
68102 --> $DIR/offset-of-tuple-field.rs:19:47
69103 |
70104LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.1e2);
71105 | ^^^
106 |
107 = note: available fields are: `0`, `1`
72108
73109error[E0609]: no field `0` on type `u8`
74110 --> $DIR/offset-of-tuple-field.rs:21:49
tests/ui/parser/float-field.stderr+6
......@@ -305,6 +305,8 @@ error[E0609]: no field `1e1` on type `(u8, u8)`
305305 |
306306LL | { s.1.1e1; }
307307 | ^^^ unknown field
308 |
309 = note: available fields are: `0`, `1`
308310
309311error[E0609]: no field `0x1e1` on type `S`
310312 --> $DIR/float-field.rs:34:9
......@@ -343,12 +345,16 @@ error[E0609]: no field `f32` on type `(u8, u8)`
343345 |
344346LL | { s.1.f32; }
345347 | ^^^ unknown field
348 |
349 = note: available fields are: `0`, `1`
346350
347351error[E0609]: no field `1e1` on type `(u8, u8)`
348352 --> $DIR/float-field.rs:71:9
349353 |
350354LL | { s.1.1e1f32; }
351355 | ^^^^^^^^ unknown field
356 |
357 = note: available fields are: `0`, `1`
352358
353359error: aborting due to 57 previous errors
354360
tests/ui/parser/macro/macro-attr-bad.rs created+32
......@@ -0,0 +1,32 @@
1#![crate_type = "lib"]
2#![feature(macro_attr)]
3
4macro_rules! attr_incomplete_1 { attr }
5//~^ ERROR macro definition ended unexpectedly
6
7macro_rules! attr_incomplete_2 { attr() }
8//~^ ERROR macro definition ended unexpectedly
9
10macro_rules! attr_incomplete_3 { attr() {} }
11//~^ ERROR expected `=>`
12
13macro_rules! attr_incomplete_4 { attr() {} => }
14//~^ ERROR macro definition ended unexpectedly
15
16macro_rules! attr_noparens_1 { attr{} {} => {} }
17//~^ ERROR macro attribute argument matchers require parentheses
18
19macro_rules! attr_noparens_2 { attr[] {} => {} }
20//~^ ERROR macro attribute argument matchers require parentheses
21
22macro_rules! attr_noparens_3 { attr _ {} => {} }
23//~^ ERROR invalid macro matcher
24
25macro_rules! attr_dup_matcher_1 { attr() {$x:ident $x:ident} => {} }
26//~^ ERROR duplicate matcher binding
27
28macro_rules! attr_dup_matcher_2 { attr($x:ident $x:ident) {} => {} }
29//~^ ERROR duplicate matcher binding
30
31macro_rules! attr_dup_matcher_3 { attr($x:ident) {$x:ident} => {} }
32//~^ ERROR duplicate matcher binding
tests/ui/parser/macro/macro-attr-bad.stderr created+80
......@@ -0,0 +1,80 @@
1error: macro definition ended unexpectedly
2 --> $DIR/macro-attr-bad.rs:4:38
3 |
4LL | macro_rules! attr_incomplete_1 { attr }
5 | ^ expected macro attr args
6
7error: macro definition ended unexpectedly
8 --> $DIR/macro-attr-bad.rs:7:40
9 |
10LL | macro_rules! attr_incomplete_2 { attr() }
11 | ^ expected macro attr body
12
13error: expected `=>`, found end of macro arguments
14 --> $DIR/macro-attr-bad.rs:10:43
15 |
16LL | macro_rules! attr_incomplete_3 { attr() {} }
17 | ^ expected `=>`
18
19error: macro definition ended unexpectedly
20 --> $DIR/macro-attr-bad.rs:13:46
21 |
22LL | macro_rules! attr_incomplete_4 { attr() {} => }
23 | ^ expected right-hand side of macro rule
24
25error: macro attribute argument matchers require parentheses
26 --> $DIR/macro-attr-bad.rs:16:36
27 |
28LL | macro_rules! attr_noparens_1 { attr{} {} => {} }
29 | ^^
30 |
31help: the delimiters should be `(` and `)`
32 |
33LL - macro_rules! attr_noparens_1 { attr{} {} => {} }
34LL + macro_rules! attr_noparens_1 { attr() {} => {} }
35 |
36
37error: macro attribute argument matchers require parentheses
38 --> $DIR/macro-attr-bad.rs:19:36
39 |
40LL | macro_rules! attr_noparens_2 { attr[] {} => {} }
41 | ^^
42 |
43help: the delimiters should be `(` and `)`
44 |
45LL - macro_rules! attr_noparens_2 { attr[] {} => {} }
46LL + macro_rules! attr_noparens_2 { attr() {} => {} }
47 |
48
49error: invalid macro matcher; matchers must be contained in balanced delimiters
50 --> $DIR/macro-attr-bad.rs:22:37
51 |
52LL | macro_rules! attr_noparens_3 { attr _ {} => {} }
53 | ^
54
55error: duplicate matcher binding
56 --> $DIR/macro-attr-bad.rs:25:52
57 |
58LL | macro_rules! attr_dup_matcher_1 { attr() {$x:ident $x:ident} => {} }
59 | -------- ^^^^^^^^ duplicate binding
60 | |
61 | previous binding
62
63error: duplicate matcher binding
64 --> $DIR/macro-attr-bad.rs:28:49
65 |
66LL | macro_rules! attr_dup_matcher_2 { attr($x:ident $x:ident) {} => {} }
67 | -------- ^^^^^^^^ duplicate binding
68 | |
69 | previous binding
70
71error: duplicate matcher binding
72 --> $DIR/macro-attr-bad.rs:31:51
73 |
74LL | macro_rules! attr_dup_matcher_3 { attr($x:ident) {$x:ident} => {} }
75 | -------- ^^^^^^^^ duplicate binding
76 | |
77 | previous binding
78
79error: aborting due to 10 previous errors
80
tests/ui/parser/macro/macro-attr-recovery.rs created+19
......@@ -0,0 +1,19 @@
1#![crate_type = "lib"]
2#![feature(macro_attr)]
3
4macro_rules! attr {
5 attr[$($args:tt)*] { $($body:tt)* } => {
6 //~^ ERROR: macro attribute argument matchers require parentheses
7 //~v ERROR: attr:
8 compile_error!(concat!(
9 "attr: args=\"",
10 stringify!($($args)*),
11 "\" body=\"",
12 stringify!($($body)*),
13 "\"",
14 ));
15 };
16}
17
18#[attr]
19struct S;
tests/ui/parser/macro/macro-attr-recovery.stderr created+31
......@@ -0,0 +1,31 @@
1error: macro attribute argument matchers require parentheses
2 --> $DIR/macro-attr-recovery.rs:5:9
3 |
4LL | attr[$($args:tt)*] { $($body:tt)* } => {
5 | ^^^^^^^^^^^^^^
6 |
7help: the delimiters should be `(` and `)`
8 |
9LL - attr[$($args:tt)*] { $($body:tt)* } => {
10LL + attr($($args:tt)*) { $($body:tt)* } => {
11 |
12
13error: attr: args="" body="struct S;"
14 --> $DIR/macro-attr-recovery.rs:8:9
15 |
16LL | / compile_error!(concat!(
17LL | | "attr: args=\"",
18LL | | stringify!($($args)*),
19LL | | "\" body=\"",
20LL | | stringify!($($body)*),
21LL | | "\"",
22LL | | ));
23 | |__________^
24...
25LL | #[attr]
26 | ------- in this attribute macro expansion
27 |
28 = note: this error originates in the attribute macro `attr` (in Nightly builds, run with -Z macro-backtrace for more info)
29
30error: aborting due to 2 previous errors
31
tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.rs+1-1
......@@ -15,7 +15,7 @@ fn main() {
1515 }
1616
1717 match Box::new((true, Box::new(false))) {
18 //~^ ERROR non-exhaustive patterns: `deref!((false, deref!(false)))` and `deref!((true, deref!(true)))` not covered
18 //~^ ERROR non-exhaustive patterns: `deref!((true, deref!(true)))` and `deref!((false, deref!(false)))` not covered
1919 (true, false) => {}
2020 (false, true) => {}
2121 }
tests/ui/pattern/deref-patterns/usefulness/non-exhaustive.stderr+3-3
......@@ -28,11 +28,11 @@ LL ~ true => {},
2828LL + deref!(deref!(false)) => todo!()
2929 |
3030
31error[E0004]: non-exhaustive patterns: `deref!((false, deref!(false)))` and `deref!((true, deref!(true)))` not covered
31error[E0004]: non-exhaustive patterns: `deref!((true, deref!(true)))` and `deref!((false, deref!(false)))` not covered
3232 --> $DIR/non-exhaustive.rs:17:11
3333 |
3434LL | match Box::new((true, Box::new(false))) {
35 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ patterns `deref!((false, deref!(false)))` and `deref!((true, deref!(true)))` not covered
35 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ patterns `deref!((true, deref!(true)))` and `deref!((false, deref!(false)))` not covered
3636 |
3737note: `Box<(bool, Box<bool>)>` defined here
3838 --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
......@@ -40,7 +40,7 @@ note: `Box<(bool, Box<bool>)>` defined here
4040help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
4141 |
4242LL ~ (false, true) => {},
43LL + deref!((false, deref!(false))) | deref!((true, deref!(true))) => todo!()
43LL + deref!((true, deref!(true))) | deref!((false, deref!(false))) => todo!()
4444 |
4545
4646error[E0004]: non-exhaustive patterns: `deref!((deref!(T::C), _))` not covered
tests/ui/pattern/usefulness/unions.rs+1-1
......@@ -26,7 +26,7 @@ fn main() {
2626 }
2727 // Our approach can report duplicate witnesses sometimes.
2828 match (x, true) {
29 //~^ ERROR non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: false }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered
29 //~^ ERROR non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: true }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered
3030 (U8AsBool { b: true }, true) => {}
3131 (U8AsBool { b: false }, true) => {}
3232 (U8AsBool { n: 1.. }, true) => {}
tests/ui/pattern/usefulness/unions.stderr+2-2
......@@ -16,11 +16,11 @@ LL ~ U8AsBool { n: 1.. } => {},
1616LL + U8AsBool { n: 0_u8 } | U8AsBool { b: false } => todo!()
1717 |
1818
19error[E0004]: non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: false }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered
19error[E0004]: non-exhaustive patterns: `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: true }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered
2020 --> $DIR/unions.rs:28:15
2121 |
2222LL | match (x, true) {
23 | ^^^^^^^^^ patterns `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: false }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered
23 | ^^^^^^^^^ patterns `(U8AsBool { n: 0_u8 }, false)`, `(U8AsBool { b: true }, false)`, `(U8AsBool { n: 0_u8 }, false)` and 1 more not covered
2424 |
2525 = note: the matched value is of type `(U8AsBool, bool)`
2626help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms
tests/ui/proc-macro/span-from-proc-macro.stderr+1-1
......@@ -10,7 +10,7 @@ LL | field: MissingType
1010 ::: $DIR/span-from-proc-macro.rs:8:1
1111 |
1212LL | #[error_from_attribute]
13 | ----------------------- in this procedural macro expansion
13 | ----------------------- in this attribute macro expansion
1414
1515error[E0412]: cannot find type `OtherMissingType` in this scope
1616 --> $DIR/auxiliary/span-from-proc-macro.rs:42:21
tests/ui/recursion/issue-23122-2.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12trait Next {
23 type Next: Next;
34}
tests/ui/recursion/issue-23122-2.stderr+5-3
......@@ -1,17 +1,19 @@
11error[E0275]: overflow evaluating the requirement `<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized`
2 --> $DIR/issue-23122-2.rs:10:17
2 --> $DIR/issue-23122-2.rs:11:17
33 |
44LL | type Next = <GetNext<T::Next> as Next>::Next;
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 |
77 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`)
8note: required for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next`
9 --> $DIR/issue-23122-2.rs:9:15
8note: required for `GetNext<<<<... as Next>::Next as Next>::Next as Next>::Next>` to implement `Next`
9 --> $DIR/issue-23122-2.rs:10:15
1010 |
1111LL | impl<T: Next> Next for GetNext<T> {
1212 | - ^^^^ ^^^^^^^^^^
1313 | |
1414 | unsatisfied trait bound introduced here
15 = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-23122-2.long-type-$LONG_TYPE_HASH.txt'
16 = note: consider using `--verbose` to print the full type name to the console
1517
1618error: aborting due to 1 previous error
1719
tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs+1
......@@ -1,3 +1,4 @@
1//@ compile-flags: -Zwrite-long-types-to-disk=yes
12// `S` is infinitely recursing so it's not possible to generate a finite
23// drop impl.
34//
tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr+4-2
......@@ -1,10 +1,12 @@
11error[E0320]: overflow while adding drop-check rules for `S<u32>`
2 --> $DIR/issue-38591-non-regular-dropck-recursion.rs:11:6
2 --> $DIR/issue-38591-non-regular-dropck-recursion.rs:12:6
33 |
44LL | fn f(x: S<u32>) {}
55 | ^
66 |
7 = note: overflowed on `S<fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(u32)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))>`
7 = note: overflowed on `S<fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(...))))))))))))))))>`
8 = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-38591-non-regular-dropck-recursion.long-type-$LONG_TYPE_HASH.txt'
9 = note: consider using `--verbose` to print the full type name to the console
810
911error: aborting due to 1 previous error
1012
tests/ui/recursion/issue-83150.rs+1-1
......@@ -1,6 +1,6 @@
11//~ ERROR overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator`
22//@ build-fail
3//@ compile-flags: -Copt-level=0
3//@ compile-flags: -Copt-level=0 -Zwrite-long-types-to-disk=yes
44
55fn main() {
66 let mut iter = 0u8..1;
tests/ui/recursion/issue-83150.stderr+4-2
......@@ -13,9 +13,11 @@ LL | func(&mut iter.map(|x| x + 1))
1313error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator`
1414 |
1515 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`)
16 = note: required for `&mut Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>` to implement `Iterator`
16 = note: required for `&mut Map<&mut Range<u8>, {closure@issue-83150.rs:12:24}>` to implement `Iterator`
1717 = note: 65 redundant requirements hidden
18 = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>` to implement `Iterator`
18 = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut ..., ...>, ...>, ...>, ...>` to implement `Iterator`
19 = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-83150.long-type-$LONG_TYPE_HASH.txt'
20 = note: consider using `--verbose` to print the full type name to the console
1921
2022error: aborting due to 1 previous error; 1 warning emitted
2123
tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr+1-1
......@@ -2,7 +2,7 @@ error[E0277]: the trait bound `f32: Termination` is not satisfied
22 --> $DIR/termination-trait-test-wrong-type.rs:6:31
33 |
44LL | #[test]
5 | ------- in this procedural macro expansion
5 | ------- in this attribute macro expansion
66LL | fn can_parse_zero_as_f32() -> Result<f32, ParseFloatError> {
77 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Termination` is not implemented for `f32`
88 |
tests/ui/self/arbitrary_self_type_infinite_recursion.stderr+1-1
......@@ -32,7 +32,7 @@ LL | p.method();
3232 |
3333 = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`arbitrary_self_type_infinite_recursion`)
3434
35error[E0599]: no method named `method` found for struct `MySmartPtr` in the current scope
35error[E0599]: no method named `method` found for struct `MySmartPtr<T>` in the current scope
3636 --> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5
3737 |
3838LL | struct MySmartPtr<T>(T);
tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr+2-2
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `frobnicate_ref` found for struct `CppRef` in the current scope
1error[E0599]: no method named `frobnicate_ref` found for struct `CppRef<T>` in the current scope
22 --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:29:17
33 |
44LL | struct CppRef<T>(T);
......@@ -16,7 +16,7 @@ help: there is a method `frobnicate_cpp_ref` with a similar name
1616LL | foo_cpp_ref.frobnicate_cpp_ref();
1717 | ++++
1818
19error[E0599]: no method named `frobnicate_self` found for struct `CppRef` in the current scope
19error[E0599]: no method named `frobnicate_self` found for struct `CppRef<T>` in the current scope
2020 --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:32:17
2121 |
2222LL | struct CppRef<T>(T);
tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs+1-1
......@@ -9,5 +9,5 @@ impl S {
99fn main() {
1010 Pin::new(S).x();
1111 //~^ ERROR the trait bound `S: Deref` is not satisfied
12 //~| ERROR no method named `x` found for struct `Pin` in the current scope
12 //~| ERROR no method named `x` found for struct `Pin<Ptr>` in the current scope
1313}
tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr+1-1
......@@ -15,7 +15,7 @@ LL | Pin::new(&S).x();
1515LL | Pin::new(&mut S).x();
1616 | ++++
1717
18error[E0599]: no method named `x` found for struct `Pin` in the current scope
18error[E0599]: no method named `x` found for struct `Pin<Ptr>` in the current scope
1919 --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:17
2020 |
2121LL | Pin::new(S).x();
tests/ui/simd/libm_no_std_cant_float.stderr+6-6
......@@ -1,34 +1,34 @@
1error[E0599]: no method named `ceil` found for struct `Simd` in the current scope
1error[E0599]: no method named `ceil` found for struct `Simd<T, N>` in the current scope
22 --> $DIR/libm_no_std_cant_float.rs:15:17
33 |
44LL | let _xc = x.ceil();
55 | ^^^^ method not found in `Simd<f32, 4>`
66
7error[E0599]: no method named `floor` found for struct `Simd` in the current scope
7error[E0599]: no method named `floor` found for struct `Simd<T, N>` in the current scope
88 --> $DIR/libm_no_std_cant_float.rs:16:17
99 |
1010LL | let _xf = x.floor();
1111 | ^^^^^ method not found in `Simd<f32, 4>`
1212
13error[E0599]: no method named `round` found for struct `Simd` in the current scope
13error[E0599]: no method named `round` found for struct `Simd<T, N>` in the current scope
1414 --> $DIR/libm_no_std_cant_float.rs:17:17
1515 |
1616LL | let _xr = x.round();
1717 | ^^^^^ method not found in `Simd<f32, 4>`
1818
19error[E0599]: no method named `trunc` found for struct `Simd` in the current scope
19error[E0599]: no method named `trunc` found for struct `Simd<T, N>` in the current scope
2020 --> $DIR/libm_no_std_cant_float.rs:18:17
2121 |
2222LL | let _xt = x.trunc();
2323 | ^^^^^ method not found in `Simd<f32, 4>`
2424
25error[E0599]: no method named `mul_add` found for struct `Simd` in the current scope
25error[E0599]: no method named `mul_add` found for struct `Simd<T, N>` in the current scope
2626 --> $DIR/libm_no_std_cant_float.rs:19:19
2727 |
2828LL | let _xfma = x.mul_add(x, x);
2929 | ^^^^^^^ method not found in `Simd<f32, 4>`
3030
31error[E0599]: no method named `sqrt` found for struct `Simd` in the current scope
31error[E0599]: no method named `sqrt` found for struct `Simd<T, N>` in the current scope
3232 --> $DIR/libm_no_std_cant_float.rs:20:20
3333 |
3434LL | let _xsqrt = x.sqrt();
tests/ui/structs/tuple-struct-field-naming-47073.stderr+1-5
......@@ -4,11 +4,7 @@ error[E0609]: no field `00` on type `Verdict`
44LL | let _condemned = justice.00;
55 | ^^ unknown field
66 |
7help: a field with a similar name exists
8 |
9LL - let _condemned = justice.00;
10LL + let _condemned = justice.0;
11 |
7 = note: available fields are: `0`, `1`
128
139error[E0609]: no field `001` on type `Verdict`
1410 --> $DIR/tuple-struct-field-naming-47073.rs:11:31
tests/ui/suggestions/enum-method-probe.fixed+6-6
......@@ -14,7 +14,7 @@ impl Foo {
1414fn test_result_in_result() -> Result<(), ()> {
1515 let res: Result<_, ()> = Ok(Foo);
1616 res?.get();
17 //~^ ERROR no method named `get` found for enum `Result` in the current scope
17 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
1818 //~| HELP use the `?` operator
1919 Ok(())
2020}
......@@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> {
2222async fn async_test_result_in_result() -> Result<(), ()> {
2323 let res: Result<_, ()> = Ok(Foo);
2424 res?.get();
25 //~^ ERROR no method named `get` found for enum `Result` in the current scope
25 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
2626 //~| HELP use the `?` operator
2727 Ok(())
2828}
......@@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> {
3030fn test_result_in_unit_return() {
3131 let res: Result<_, ()> = Ok(Foo);
3232 res.expect("REASON").get();
33 //~^ ERROR no method named `get` found for enum `Result` in the current scope
33 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
3434 //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
3535}
3636
3737async fn async_test_result_in_unit_return() {
3838 let res: Result<_, ()> = Ok(Foo);
3939 res.expect("REASON").get();
40 //~^ ERROR no method named `get` found for enum `Result` in the current scope
40 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
4141 //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
4242}
4343
4444fn test_option_in_option() -> Option<()> {
4545 let res: Option<_> = Some(Foo);
4646 res?.get();
47 //~^ ERROR no method named `get` found for enum `Option` in the current scope
47 //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope
4848 //~| HELP use the `?` operator
4949 Some(())
5050}
......@@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> {
5252fn test_option_in_unit_return() {
5353 let res: Option<_> = Some(Foo);
5454 res.expect("REASON").get();
55 //~^ ERROR no method named `get` found for enum `Option` in the current scope
55 //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope
5656 //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
5757}
5858
tests/ui/suggestions/enum-method-probe.rs+6-6
......@@ -14,7 +14,7 @@ impl Foo {
1414fn test_result_in_result() -> Result<(), ()> {
1515 let res: Result<_, ()> = Ok(Foo);
1616 res.get();
17 //~^ ERROR no method named `get` found for enum `Result` in the current scope
17 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
1818 //~| HELP use the `?` operator
1919 Ok(())
2020}
......@@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> {
2222async fn async_test_result_in_result() -> Result<(), ()> {
2323 let res: Result<_, ()> = Ok(Foo);
2424 res.get();
25 //~^ ERROR no method named `get` found for enum `Result` in the current scope
25 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
2626 //~| HELP use the `?` operator
2727 Ok(())
2828}
......@@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> {
3030fn test_result_in_unit_return() {
3131 let res: Result<_, ()> = Ok(Foo);
3232 res.get();
33 //~^ ERROR no method named `get` found for enum `Result` in the current scope
33 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
3434 //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
3535}
3636
3737async fn async_test_result_in_unit_return() {
3838 let res: Result<_, ()> = Ok(Foo);
3939 res.get();
40 //~^ ERROR no method named `get` found for enum `Result` in the current scope
40 //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
4141 //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
4242}
4343
4444fn test_option_in_option() -> Option<()> {
4545 let res: Option<_> = Some(Foo);
4646 res.get();
47 //~^ ERROR no method named `get` found for enum `Option` in the current scope
47 //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope
4848 //~| HELP use the `?` operator
4949 Some(())
5050}
......@@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> {
5252fn test_option_in_unit_return() {
5353 let res: Option<_> = Some(Foo);
5454 res.get();
55 //~^ ERROR no method named `get` found for enum `Option` in the current scope
55 //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope
5656 //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
5757}
5858
tests/ui/suggestions/enum-method-probe.stderr+6-6
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `get` found for enum `Result` in the current scope
1error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope
22 --> $DIR/enum-method-probe.rs:24:9
33 |
44LL | res.get();
......@@ -14,7 +14,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er
1414LL | res?.get();
1515 | +
1616
17error[E0599]: no method named `get` found for enum `Result` in the current scope
17error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope
1818 --> $DIR/enum-method-probe.rs:39:9
1919 |
2020LL | res.get();
......@@ -30,7 +30,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th
3030LL | res.expect("REASON").get();
3131 | +++++++++++++++++
3232
33error[E0599]: no method named `get` found for enum `Result` in the current scope
33error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope
3434 --> $DIR/enum-method-probe.rs:16:9
3535 |
3636LL | res.get();
......@@ -46,7 +46,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er
4646LL | res?.get();
4747 | +
4848
49error[E0599]: no method named `get` found for enum `Result` in the current scope
49error[E0599]: no method named `get` found for enum `Result<T, E>` in the current scope
5050 --> $DIR/enum-method-probe.rs:32:9
5151 |
5252LL | res.get();
......@@ -62,7 +62,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th
6262LL | res.expect("REASON").get();
6363 | +++++++++++++++++
6464
65error[E0599]: no method named `get` found for enum `Option` in the current scope
65error[E0599]: no method named `get` found for enum `Option<T>` in the current scope
6666 --> $DIR/enum-method-probe.rs:46:9
6767 |
6868LL | res.get();
......@@ -78,7 +78,7 @@ help: use the `?` operator to extract the `Foo` value, propagating an `Option::N
7878LL | res?.get();
7979 | +
8080
81error[E0599]: no method named `get` found for enum `Option` in the current scope
81error[E0599]: no method named `get` found for enum `Option<T>` in the current scope
8282 --> $DIR/enum-method-probe.rs:54:9
8383 |
8484LL | res.get();
tests/ui/suggestions/field-has-method.rs+1-1
......@@ -17,7 +17,7 @@ struct InferOk<T> {
1717
1818fn foo(i: InferOk<Ty>) {
1919 let k = i.kind();
20 //~^ ERROR no method named `kind` found for struct `InferOk` in the current scope
20 //~^ ERROR no method named `kind` found for struct `InferOk<T>` in the current scope
2121}
2222
2323fn main() {}
tests/ui/suggestions/field-has-method.stderr+1-1
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `kind` found for struct `InferOk` in the current scope
1error[E0599]: no method named `kind` found for struct `InferOk<T>` in the current scope
22 --> $DIR/field-has-method.rs:19:15
33 |
44LL | struct InferOk<T> {
tests/ui/suggestions/inner_type.fixed+5-5
......@@ -15,26 +15,26 @@ fn main() {
1515 let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
1616
1717 other_item.borrow().method();
18 //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599]
18 //~^ ERROR no method named `method` found for struct `RefCell<T>` in the current scope [E0599]
1919 //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
2020
2121 other_item.borrow_mut().some_mutable_method();
22 //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599]
22 //~^ ERROR no method named `some_mutable_method` found for struct `RefCell<T>` in the current scope [E0599]
2323 //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
2424
2525 let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
2626
2727 another_item.lock().unwrap().method();
28 //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599]
28 //~^ ERROR no method named `method` found for struct `std::sync::Mutex<T>` in the current scope [E0599]
2929 //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
3030
3131 let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
3232
3333 another_item.read().unwrap().method();
34 //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599]
34 //~^ ERROR no method named `method` found for struct `RwLock<T>` in the current scope [E0599]
3535 //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
3636
3737 another_item.write().unwrap().some_mutable_method();
38 //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599]
38 //~^ ERROR no method named `some_mutable_method` found for struct `RwLock<T>` in the current scope [E0599]
3939 //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
4040}
tests/ui/suggestions/inner_type.rs+5-5
......@@ -15,26 +15,26 @@ fn main() {
1515 let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
1616
1717 other_item.method();
18 //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599]
18 //~^ ERROR no method named `method` found for struct `RefCell<T>` in the current scope [E0599]
1919 //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
2020
2121 other_item.some_mutable_method();
22 //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599]
22 //~^ ERROR no method named `some_mutable_method` found for struct `RefCell<T>` in the current scope [E0599]
2323 //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
2424
2525 let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
2626
2727 another_item.method();
28 //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599]
28 //~^ ERROR no method named `method` found for struct `std::sync::Mutex<T>` in the current scope [E0599]
2929 //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
3030
3131 let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
3232
3333 another_item.method();
34 //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599]
34 //~^ ERROR no method named `method` found for struct `RwLock<T>` in the current scope [E0599]
3535 //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
3636
3737 another_item.some_mutable_method();
38 //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599]
38 //~^ ERROR no method named `some_mutable_method` found for struct `RwLock<T>` in the current scope [E0599]
3939 //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
4040}
tests/ui/suggestions/inner_type.stderr+5-5
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `method` found for struct `RefCell` in the current scope
1error[E0599]: no method named `method` found for struct `RefCell<T>` in the current scope
22 --> $DIR/inner_type.rs:17:16
33 |
44LL | other_item.method();
......@@ -14,7 +14,7 @@ help: use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow
1414LL | other_item.borrow().method();
1515 | +++++++++
1616
17error[E0599]: no method named `some_mutable_method` found for struct `RefCell` in the current scope
17error[E0599]: no method named `some_mutable_method` found for struct `RefCell<T>` in the current scope
1818 --> $DIR/inner_type.rs:21:16
1919 |
2020LL | other_item.some_mutable_method();
......@@ -30,7 +30,7 @@ help: use `.borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any
3030LL | other_item.borrow_mut().some_mutable_method();
3131 | +++++++++++++
3232
33error[E0599]: no method named `method` found for struct `std::sync::Mutex` in the current scope
33error[E0599]: no method named `method` found for struct `std::sync::Mutex<T>` in the current scope
3434 --> $DIR/inner_type.rs:27:18
3535 |
3636LL | another_item.method();
......@@ -46,7 +46,7 @@ help: use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current t
4646LL | another_item.lock().unwrap().method();
4747 | ++++++++++++++++
4848
49error[E0599]: no method named `method` found for struct `RwLock` in the current scope
49error[E0599]: no method named `method` found for struct `RwLock<T>` in the current scope
5050 --> $DIR/inner_type.rs:33:18
5151 |
5252LL | another_item.method();
......@@ -62,7 +62,7 @@ help: use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current t
6262LL | another_item.read().unwrap().method();
6363 | ++++++++++++++++
6464
65error[E0599]: no method named `some_mutable_method` found for struct `RwLock` in the current scope
65error[E0599]: no method named `some_mutable_method` found for struct `RwLock<T>` in the current scope
6666 --> $DIR/inner_type.rs:37:18
6767 |
6868LL | another_item.some_mutable_method();
tests/ui/suggestions/inner_type2.rs+2-2
......@@ -16,11 +16,11 @@ thread_local! {
1616
1717fn main() {
1818 STRUCT.method();
19 //~^ ERROR no method named `method` found for struct `LocalKey` in the current scope [E0599]
19 //~^ ERROR no method named `method` found for struct `LocalKey<T>` in the current scope [E0599]
2020 //~| HELP use `with` or `try_with` to access thread local storage
2121
2222 let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 });
2323 item.method();
24 //~^ ERROR no method named `method` found for union `MaybeUninit` in the current scope [E0599]
24 //~^ ERROR no method named `method` found for union `MaybeUninit<T>` in the current scope [E0599]
2525 //~| HELP if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value
2626}
tests/ui/suggestions/inner_type2.stderr+2-2
......@@ -1,4 +1,4 @@
1error[E0599]: no method named `method` found for struct `LocalKey` in the current scope
1error[E0599]: no method named `method` found for struct `LocalKey<T>` in the current scope
22 --> $DIR/inner_type2.rs:18:12
33 |
44LL | STRUCT.method();
......@@ -11,7 +11,7 @@ note: the method `method` exists on the type `Struct<u32>`
1111LL | pub fn method(&self) {}
1212 | ^^^^^^^^^^^^^^^^^^^^
1313
14error[E0599]: no method named `method` found for union `MaybeUninit` in the current scope
14error[E0599]: no method named `method` found for union `MaybeUninit<T>` in the current scope
1515 --> $DIR/inner_type2.rs:23:10
1616 |
1717LL | item.method();
tests/ui/test-attrs/issue-12997-2.stderr+1-1
......@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22 --> $DIR/issue-12997-2.rs:8:1
33 |
44LL | #[bench]
5 | -------- in this procedural macro expansion
5 | -------- in this attribute macro expansion
66LL | fn bar(x: isize) { }
77 | ^^^^^^^^^^^^^^^^^^^^
88 | |
tests/ui/test-attrs/test-function-signature.stderr+1-1
......@@ -26,7 +26,7 @@ error[E0277]: the trait bound `i32: Termination` is not satisfied
2626 --> $DIR/test-function-signature.rs:9:13
2727 |
2828LL | #[test]
29 | ------- in this procedural macro expansion
29 | ------- in this attribute macro expansion
3030LL | fn bar() -> i32 {
3131 | ^^^ the trait `Termination` is not implemented for `i32`
3232 |
tests/ui/traits/issue-91949-hangs-on-recursion.rs+1-1
......@@ -1,6 +1,6 @@
11//~ ERROR overflow evaluating the requirement `<std::iter::Empty<()> as Iterator>::Item == ()`
22//@ build-fail
3//@ compile-flags: -Zinline-mir=no
3//@ compile-flags: -Zinline-mir=no -Zwrite-long-types-to-disk=yes
44
55// Regression test for #91949.
66// This hanged *forever* on 1.56, fixed by #90423.
tests/ui/traits/issue-91949-hangs-on-recursion.stderr+3-1
......@@ -24,7 +24,9 @@ LL | impl<T, I: Iterator<Item = T>> Iterator for IteratorOfWrapped<T, I> {
2424 | |
2525 | unsatisfied trait bound introduced here
2626 = note: 256 redundant requirements hidden
27 = note: required for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), std::iter::Empty<()>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>` to implement `Iterator`
27 = note: required for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<..., ...>>, ...>>` to implement `Iterator`
28 = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-91949-hangs-on-recursion.long-type-$LONG_TYPE_HASH.txt'
29 = note: consider using `--verbose` to print the full type name to the console
2830
2931error: aborting due to 1 previous error; 1 warning emitted
3032
tests/ui/traits/well-formed-recursion-limit.stderr+4
......@@ -3,12 +3,16 @@ error[E0609]: no field `ab` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'sta
33 |
44LL | let (ab, ba) = (i.ab, i.ba);
55 | ^^ unknown field
6 |
7 = note: available fields are: `0`, `1`
68
79error[E0609]: no field `ba` on type `(Box<(dyn Fn(Option<A>) -> Option<B> + 'static)>, Box<(dyn Fn(Option<B>) -> Option<A> + 'static)>)`
810 --> $DIR/well-formed-recursion-limit.rs:12:29
911 |
1012LL | let (ab, ba) = (i.ab, i.ba);
1113 | ^^ unknown field
14 |
15 = note: available fields are: `0`, `1`
1216
1317error[E0275]: overflow assigning `_` to `Option<_>`
1418 --> $DIR/well-formed-recursion-limit.rs:15:33
tests/ui/tuple/index-invalid.stderr+6
......@@ -3,18 +3,24 @@ error[E0609]: no field `1` on type `(((),),)`
33 |
44LL | let _ = (((),),).1.0;
55 | ^ unknown field
6 |
7 = note: available field is: `0`
68
79error[E0609]: no field `1` on type `((),)`
810 --> $DIR/index-invalid.rs:4:24
911 |
1012LL | let _ = (((),),).0.1;
1113 | ^ unknown field
14 |
15 = note: available field is: `0`
1216
1317error[E0609]: no field `000` on type `(((),),)`
1418 --> $DIR/index-invalid.rs:6:22
1519 |
1620LL | let _ = (((),),).000.000;
1721 | ^^^ unknown field
22 |
23 = note: available field is: `0`
1824
1925error: aborting due to 3 previous errors
2026
tests/ui/tuple/missing-field-access.rs created+16
......@@ -0,0 +1,16 @@
1// Ensure that suggestions to search for missing intermediary field accesses are available for both
2// tuple structs *and* regular tuples.
3// Ensure that we do not suggest pinning the expression just because `Pin::get_ref` exists.
4// https://github.com/rust-lang/rust/issues/144602
5use std::{fs::File, io::BufReader};
6
7struct F(BufReader<File>);
8
9fn main() {
10 let f = F(BufReader::new(File::open("x").unwrap()));
11 let x = f.get_ref(); //~ ERROR E0599
12 //~^ HELP one of the expressions' fields has a method of the same name
13 let f = (BufReader::new(File::open("x").unwrap()), );
14 let x = f.get_ref(); //~ ERROR E0599
15 //~^ HELP one of the expressions' fields has a method of the same name
16}
tests/ui/tuple/missing-field-access.stderr created+28
......@@ -0,0 +1,28 @@
1error[E0599]: no method named `get_ref` found for struct `F` in the current scope
2 --> $DIR/missing-field-access.rs:11:15
3 |
4LL | struct F(BufReader<File>);
5 | -------- method `get_ref` not found for this struct
6...
7LL | let x = f.get_ref();
8 | ^^^^^^^ method not found in `F`
9 |
10help: one of the expressions' fields has a method of the same name
11 |
12LL | let x = f.0.get_ref();
13 | ++
14
15error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope
16 --> $DIR/missing-field-access.rs:14:15
17 |
18LL | let x = f.get_ref();
19 | ^^^^^^^ method not found in `(BufReader<File>,)`
20 |
21help: one of the expressions' fields has a method of the same name
22 |
23LL | let x = f.0.get_ref();
24 | ++
25
26error: aborting due to 2 previous errors
27
28For more information about this error, try `rustc --explain E0599`.
tests/ui/tuple/tuple-index-out-of-bounds.stderr+3-5
......@@ -4,17 +4,15 @@ error[E0609]: no field `2` on type `Point`
44LL | origin.2;
55 | ^ unknown field
66 |
7help: a field with a similar name exists
8 |
9LL - origin.2;
10LL + origin.0;
11 |
7 = note: available fields are: `0`, `1`
128
139error[E0609]: no field `2` on type `({integer}, {integer})`
1410 --> $DIR/tuple-index-out-of-bounds.rs:12:11
1511 |
1612LL | tuple.2;
1713 | ^ unknown field
14 |
15 = note: available fields are: `0`, `1`
1816
1917error: aborting due to 2 previous errors
2018