| author | bors <bors@rust-lang.org> 2026-05-15 21:40:32 UTC |
| committer | bors <bors@rust-lang.org> 2026-05-15 21:40:32 UTC |
| log | 35143615544ede08a47947901cd4a6b7c5ecd450 |
| tree | 67582655799137eb9235dcea23d8908100a2f135 |
| parent | d7f14d3d89c39b2c12ed4b9864a0eb2c205d20bc |
| parent | d1da72ad21d0cccee1c52a67d1b23ab736112881 |
Rollup of 12 pull requests
Successful merges:
- rust-lang/rust#148788 (Unconstrained parameter fix)
- rust-lang/rust#156319 (Require EIIs to be defined when we compile a rust dylib)
- rust-lang/rust#156452 (Implement pinned drop sugar)
- rust-lang/rust#156554 (Allow user-provided `llvm_args` to override target spec arguments)
- rust-lang/rust#156571 (Disable `main_needs_argc_argv` for Wasm)
- rust-lang/rust#156600 (Make const param default test reproduce original ICE)
- rust-lang/rust#156493 (actually run the temp_dir doctest)
- rust-lang/rust#156556 (Require UTF-8 in `Utf8Pattern::StringPattern`)
- rust-lang/rust#156565 (delegation: emit error when self type is not specified and accessed)
- rust-lang/rust#156586 (Use DropCtxt::new_block and new_block_with_statements systematically.)
- rust-lang/rust#156587 (Correctly handle associated items in rustdoc macro expansion)
- rust-lang/rust#156604 (coverage: Reduce and clarify the context-mismatch test case)85 files changed, 1860 insertions(+), 395 deletions(-)
compiler/rustc_ast/src/ast.rs+13| ... | ... | @@ -3867,6 +3867,19 @@ pub struct Fn { |
| 3867 | 3867 | pub eii_impls: ThinVec<EiiImpl>, |
| 3868 | 3868 | } |
| 3869 | 3869 | |
| 3870 | impl Fn { | |
| 3871 | pub fn is_pin_drop_sugar(&self) -> bool { | |
| 3872 | self.ident.name == sym::drop | |
| 3873 | && self | |
| 3874 | .sig | |
| 3875 | .decl | |
| 3876 | .inputs | |
| 3877 | .first() | |
| 3878 | .and_then(|param| param.to_self()) | |
| 3879 | .is_some_and(|eself| matches!(eself.node, SelfKind::Pinned(None, Mutability::Mut))) | |
| 3880 | } | |
| 3881 | } | |
| 3882 | ||
| 3870 | 3883 | #[derive(Clone, Encodable, Decodable, Debug, Walkable)] |
| 3871 | 3884 | pub struct EiiImpl { |
| 3872 | 3885 | pub node_id: NodeId, |
compiler/rustc_ast_lowering/src/item.rs+56-17| ... | ... | @@ -1192,6 +1192,52 @@ impl<'hir> LoweringContext<'_, 'hir> { |
| 1192 | 1192 | }) |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | fn resolve_pin_drop_sugar_impl_item( | |
| 1196 | &self, | |
| 1197 | i: &AssocItem, | |
| 1198 | ident: Ident, | |
| 1199 | span: Span, | |
| 1200 | ) -> (Ident, Result<DefId, ErrorGuaranteed>) { | |
| 1201 | let trait_item_def_id = self | |
| 1202 | .get_partial_res(i.id) | |
| 1203 | .and_then(|r| r.expect_full_res().opt_def_id()) | |
| 1204 | .ok_or_else(|| { | |
| 1205 | self.dcx().span_delayed_bug(span, "could not resolve trait item being implemented") | |
| 1206 | }); | |
| 1207 | ||
| 1208 | let is_pin_drop_sugar = match &i.kind { | |
| 1209 | AssocItemKind::Fn(fn_kind) => fn_kind.is_pin_drop_sugar(), | |
| 1210 | _ => false, | |
| 1211 | }; | |
| 1212 | let def_id = match trait_item_def_id { | |
| 1213 | Ok(def_id) => def_id, | |
| 1214 | Err(guar) => return (ident, Err(guar)), | |
| 1215 | }; | |
| 1216 | if !is_pin_drop_sugar { | |
| 1217 | return (ident, Ok(def_id)); | |
| 1218 | } | |
| 1219 | ||
| 1220 | let is_drop_pin_drop = self | |
| 1221 | .tcx | |
| 1222 | .lang_items() | |
| 1223 | .drop_trait() | |
| 1224 | .is_some_and(|drop_trait| self.tcx.parent(def_id) == drop_trait); | |
| 1225 | if is_drop_pin_drop { | |
| 1226 | // Associated item collection still derives the impl item's name from HIR. | |
| 1227 | return (Ident::new(sym::pin_drop, ident.span), Ok(def_id)); | |
| 1228 | } | |
| 1229 | ||
| 1230 | let guar = self | |
| 1231 | .dcx() | |
| 1232 | .struct_span_err( | |
| 1233 | i.span, | |
| 1234 | "method `drop` with `&pin mut self` is only supported for the `Drop` trait", | |
| 1235 | ) | |
| 1236 | .with_span_label(i.span, "not a `Drop::pin_drop` implementation") | |
| 1237 | .emit(); | |
| 1238 | (ident, Err(guar)) | |
| 1239 | } | |
| 1240 | ||
| 1195 | 1241 | fn lower_impl_item( |
| 1196 | 1242 | &mut self, |
| 1197 | 1243 | i: &AssocItem, |
| ... | ... | @@ -1309,26 +1355,19 @@ impl<'hir> LoweringContext<'_, 'hir> { |
| 1309 | 1355 | }; |
| 1310 | 1356 | |
| 1311 | 1357 | let span = self.lower_span(i.span); |
| 1358 | let (effective_ident, impl_kind) = if is_in_trait_impl { | |
| 1359 | let (effective_ident, trait_item_def_id) = | |
| 1360 | self.resolve_pin_drop_sugar_impl_item(i, ident, span); | |
| 1361 | (effective_ident, ImplItemImplKind::Trait { defaultness, trait_item_def_id }) | |
| 1362 | } else { | |
| 1363 | (ident, ImplItemImplKind::Inherent { vis_span: self.lower_span(i.vis.span) }) | |
| 1364 | }; | |
| 1365 | ||
| 1312 | 1366 | let item = hir::ImplItem { |
| 1313 | 1367 | owner_id: hir_id.expect_owner(), |
| 1314 | ident: self.lower_ident(ident), | |
| 1368 | ident: self.lower_ident(effective_ident), | |
| 1315 | 1369 | generics, |
| 1316 | impl_kind: if is_in_trait_impl { | |
| 1317 | ImplItemImplKind::Trait { | |
| 1318 | defaultness, | |
| 1319 | trait_item_def_id: self | |
| 1320 | .get_partial_res(i.id) | |
| 1321 | .and_then(|r| r.expect_full_res().opt_def_id()) | |
| 1322 | .ok_or_else(|| { | |
| 1323 | self.dcx().span_delayed_bug( | |
| 1324 | span, | |
| 1325 | "could not resolve trait item being implemented", | |
| 1326 | ) | |
| 1327 | }), | |
| 1328 | } | |
| 1329 | } else { | |
| 1330 | ImplItemImplKind::Inherent { vis_span: self.lower_span(i.vis.span) } | |
| 1331 | }, | |
| 1370 | impl_kind, | |
| 1332 | 1371 | kind, |
| 1333 | 1372 | span, |
| 1334 | 1373 | has_delayed_lints: !self.delayed_lints.is_empty(), |
compiler/rustc_codegen_llvm/src/llvm_util.rs+4-1| ... | ... | @@ -66,7 +66,10 @@ unsafe fn configure_llvm(sess: &Session) { |
| 66 | 66 | |
| 67 | 67 | let cg_opts = sess.opts.cg.llvm_args.iter().map(AsRef::as_ref); |
| 68 | 68 | let tg_opts = sess.target.llvm_args.iter().map(AsRef::as_ref); |
| 69 | let sess_args = cg_opts.chain(tg_opts); | |
| 69 | // Target-spec args are passed to LLVM before user `-Cllvm-args`. LLVM's | |
| 70 | // `cl::opt` parser is last-wins, so this lets `-Cllvm-args=...` override | |
| 71 | // a value already set in the target spec (e.g. `-wasm-use-legacy-eh`). | |
| 72 | let sess_args = tg_opts.chain(cg_opts); | |
| 70 | 73 | |
| 71 | 74 | let user_specified_args: FxHashSet<_> = |
| 72 | 75 | sess_args.clone().map(|s| llvm_arg_to_arg_name(s)).filter(|s| !s.is_empty()).collect(); |
compiler/rustc_hir/src/hir.rs+87| ... | ... | @@ -1088,6 +1088,93 @@ impl<'hir> Generics<'hir> { |
| 1088 | 1088 | bound_span.with_lo(bounds[bound_pos - 1].span().hi()) |
| 1089 | 1089 | } |
| 1090 | 1090 | } |
| 1091 | ||
| 1092 | /// Computes the span representing the removal of a generic parameter at `param_index`. | |
| 1093 | /// | |
| 1094 | /// This function identifies the correct slice of source code to delete so that the | |
| 1095 | /// remaining generic list remains syntactically valid (handling commas and brackets). | |
| 1096 | /// | |
| 1097 | /// ### Examples | |
| 1098 | /// | |
| 1099 | /// 1. **With a following parameter:** (Includes the trailing comma) | |
| 1100 | /// - Input: `<T, U>` (index 0) | |
| 1101 | /// - Produces span for: `T, ` | |
| 1102 | /// | |
| 1103 | /// 2. **With a previous parameter:** (Includes the leading comma and bounds) | |
| 1104 | /// - Input: `<T: Clone, U>` (index 1) | |
| 1105 | /// - Produces span for: `, U` | |
| 1106 | /// | |
| 1107 | /// 3. **The only parameter:** (Includes the angle brackets) | |
| 1108 | /// - Input: `<T>` (index 0) | |
| 1109 | /// - Produces span for: `<T>` | |
| 1110 | /// | |
| 1111 | /// 4. **Parameter with where-clause bounds:** | |
| 1112 | /// - Input: `fn foo<T, U>() where T: Copy` (index 0) | |
| 1113 | /// - Produces span for: `T, ` (The where-clause remains for other logic to handle). | |
| 1114 | pub fn span_for_param_removal(&self, param_index: usize) -> Span { | |
| 1115 | if param_index >= self.params.len() { | |
| 1116 | return self.span.shrink_to_hi(); | |
| 1117 | } | |
| 1118 | ||
| 1119 | let is_param_explicit = |par: &&GenericParam<'_>| match par.kind { | |
| 1120 | GenericParamKind::Type { .. } | |
| 1121 | | GenericParamKind::Const { .. } | |
| 1122 | | GenericParamKind::Lifetime { kind: LifetimeParamKind::Explicit } => true, | |
| 1123 | _ => false, | |
| 1124 | }; | |
| 1125 | ||
| 1126 | // Find the span of the type parameter. | |
| 1127 | if let Some(next) = self.params[param_index + 1..].iter().find(is_param_explicit) { | |
| 1128 | self.params[param_index].span.until(next.span) | |
| 1129 | } else if let Some(prev) = self.params[..param_index].iter().rfind(is_param_explicit) { | |
| 1130 | let mut prev_span = prev.span; | |
| 1131 | // Consider the span of the bounds with the previous generic parameter when there is. | |
| 1132 | if let Some(prev_bounds_span) = self.span_for_param_bounds(prev) { | |
| 1133 | prev_span = prev_span.to(prev_bounds_span); | |
| 1134 | } | |
| 1135 | ||
| 1136 | // Consider the span of the bounds with the current generic parameter when there is. | |
| 1137 | prev_span.shrink_to_hi().to( | |
| 1138 | if let Some(cur_bounds_span) = self.span_for_param_bounds(&self.params[param_index]) | |
| 1139 | { | |
| 1140 | cur_bounds_span | |
| 1141 | } else { | |
| 1142 | self.params[param_index].span | |
| 1143 | }, | |
| 1144 | ) | |
| 1145 | } else { | |
| 1146 | // Remove also angle brackets <> when there is just ONE generic parameter. | |
| 1147 | self.span | |
| 1148 | } | |
| 1149 | } | |
| 1150 | ||
| 1151 | /// Returns the span of the `WherePredicate` associated with the given `GenericParam`, if any. | |
| 1152 | /// | |
| 1153 | /// This looks specifically for predicates in the `where` clause that were generated | |
| 1154 | /// from the parameter definition (e.g., `T` in `where T: Bound`). | |
| 1155 | /// | |
| 1156 | /// ### Example | |
| 1157 | /// | |
| 1158 | /// - Input: `param` representing `T` | |
| 1159 | /// - Context: `where T: Clone + Default, U: Copy` | |
| 1160 | /// - Returns: Span of `T: Clone + Default` | |
| 1161 | fn span_for_param_bounds(&self, param: &GenericParam<'hir>) -> Option<Span> { | |
| 1162 | self.predicates | |
| 1163 | .iter() | |
| 1164 | .find(|pred| { | |
| 1165 | if let WherePredicateKind::BoundPredicate(WhereBoundPredicate { | |
| 1166 | origin: PredicateOrigin::GenericParam, | |
| 1167 | bounded_ty, | |
| 1168 | .. | |
| 1169 | }) = pred.kind | |
| 1170 | { | |
| 1171 | bounded_ty.span == param.span | |
| 1172 | } else { | |
| 1173 | false | |
| 1174 | } | |
| 1175 | }) | |
| 1176 | .map(|pred| pred.span) | |
| 1177 | } | |
| 1091 | 1178 | } |
| 1092 | 1179 | |
| 1093 | 1180 | /// A single predicate in a where-clause. |
compiler/rustc_hir_analysis/src/delegation.rs+7| ... | ... | @@ -14,6 +14,7 @@ use rustc_middle::ty::{ |
| 14 | 14 | use rustc_span::{ErrorGuaranteed, Span, kw}; |
| 15 | 15 | |
| 16 | 16 | use crate::collect::ItemCtxt; |
| 17 | use crate::errors::DelegationSelfTypeNotSpecified; | |
| 17 | 18 | use crate::hir_ty_lowering::HirTyLowerer; |
| 18 | 19 | |
| 19 | 20 | type RemapTable = FxHashMap<u32, u32>; |
| ... | ... | @@ -284,6 +285,12 @@ fn get_delegation_self_ty_or_err(tcx: TyCtxt<'_>, delegation_id: LocalDefId) -> |
| 284 | 285 | ctx.lower_ty(tcx.hir_node(id).expect_ty()) |
| 285 | 286 | }) |
| 286 | 287 | .unwrap_or_else(|| { |
| 288 | // It is possible to attempt to get self type when it is used in signature | |
| 289 | // (i.e., `fn default() -> Self`), so emit error here in addition to possible | |
| 290 | // `mismatched types` error (see #156388). | |
| 291 | let err = DelegationSelfTypeNotSpecified { span: tcx.def_span(delegation_id) }; | |
| 292 | tcx.dcx().emit_err(err); | |
| 293 | ||
| 287 | 294 | Ty::new_error_with_message( |
| 288 | 295 | tcx, |
| 289 | 296 | tcx.def_span(delegation_id), |
compiler/rustc_hir_analysis/src/errors.rs+10| ... | ... | @@ -15,6 +15,8 @@ pub(crate) mod wrong_number_of_generic_args; |
| 15 | 15 | mod precise_captures; |
| 16 | 16 | pub(crate) use precise_captures::*; |
| 17 | 17 | |
| 18 | pub(crate) mod remove_or_use_generic; | |
| 19 | ||
| 18 | 20 | #[derive(Diagnostic)] |
| 19 | 21 | #[diag("ambiguous associated {$assoc_kind} `{$assoc_ident}` in bounds of `{$qself}`")] |
| 20 | 22 | pub(crate) struct AmbiguousAssocItem<'a> { |
| ... | ... | @@ -1670,6 +1672,14 @@ pub(crate) struct UnsupportedDelegation<'a> { |
| 1670 | 1672 | pub callee_span: Span, |
| 1671 | 1673 | } |
| 1672 | 1674 | |
| 1675 | #[derive(Diagnostic)] | |
| 1676 | #[diag("delegation self type is not specified")] | |
| 1677 | #[help("consider explicitly specifying self type: `reuse </* Type */ as Trait>::function`")] | |
| 1678 | pub(crate) struct DelegationSelfTypeNotSpecified { | |
| 1679 | #[primary_span] | |
| 1680 | pub span: Span, | |
| 1681 | } | |
| 1682 | ||
| 1673 | 1683 | #[derive(Diagnostic)] |
| 1674 | 1684 | #[diag("method should be `async` or return a future, but it is synchronous")] |
| 1675 | 1685 | pub(crate) struct MethodShouldReturnFuture { |
compiler/rustc_hir_analysis/src/errors/remove_or_use_generic.rs created+211| ... | ... | @@ -0,0 +1,211 @@ |
| 1 | use std::ops::ControlFlow; | |
| 2 | ||
| 3 | use rustc_errors::{Applicability, Diag}; | |
| 4 | use rustc_hir::def::DefKind; | |
| 5 | use rustc_hir::def_id::{DefId, LocalDefId}; | |
| 6 | use rustc_hir::intravisit::{self, Visitor, walk_lifetime}; | |
| 7 | use rustc_hir::{GenericArg, HirId, LifetimeKind, Path, QPath, TyKind}; | |
| 8 | use rustc_middle::hir::nested_filter::All; | |
| 9 | use rustc_middle::ty::{GenericParamDef, GenericParamDefKind, TyCtxt}; | |
| 10 | ||
| 11 | use crate::hir::def::Res; | |
| 12 | ||
| 13 | /// Use a Visitor to find usages of the type or lifetime parameter | |
| 14 | struct ParamUsageVisitor<'tcx> { | |
| 15 | tcx: TyCtxt<'tcx>, | |
| 16 | /// The `DefId` of the generic parameter we are looking for. | |
| 17 | param_def_id: DefId, | |
| 18 | found: bool, | |
| 19 | } | |
| 20 | ||
| 21 | impl<'tcx> Visitor<'tcx> for ParamUsageVisitor<'tcx> { | |
| 22 | type NestedFilter = All; | |
| 23 | ||
| 24 | fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt { | |
| 25 | self.tcx | |
| 26 | } | |
| 27 | ||
| 28 | type Result = ControlFlow<()>; | |
| 29 | ||
| 30 | fn visit_path(&mut self, path: &Path<'tcx>, _id: HirId) -> Self::Result { | |
| 31 | if let Some(res_def_id) = path.res.opt_def_id() { | |
| 32 | if res_def_id == self.param_def_id { | |
| 33 | self.found = true; | |
| 34 | return ControlFlow::Break(()); | |
| 35 | } | |
| 36 | } | |
| 37 | intravisit::walk_path(self, path) | |
| 38 | } | |
| 39 | ||
| 40 | fn visit_lifetime(&mut self, lifetime: &'tcx rustc_hir::Lifetime) -> Self::Result { | |
| 41 | if let LifetimeKind::Param(id) = lifetime.kind { | |
| 42 | if let Some(local_def_id) = self.param_def_id.as_local() { | |
| 43 | if id == local_def_id { | |
| 44 | self.found = true; | |
| 45 | return ControlFlow::Break(()); | |
| 46 | } | |
| 47 | } | |
| 48 | } | |
| 49 | walk_lifetime(self, lifetime) | |
| 50 | } | |
| 51 | } | |
| 52 | ||
| 53 | /// Adds a suggestion to a diagnostic to either remove an unused generic parameter, or use it. | |
| 54 | /// | |
| 55 | /// # Examples | |
| 56 | /// | |
| 57 | /// - `impl<T> Struct { ... }` where `T` is unused -> suggests removing `T` or using it. | |
| 58 | /// - `impl<T> Struct { // T used in here }` where `T` is used in the body but not in the self type -> suggests adding `T` to the self type and struct definition. | |
| 59 | /// - `impl<T> Struct { ... }` where the struct has a generic parameter with a default -> suggests adding `T` to the self type. | |
| 60 | pub(crate) fn suggest_to_remove_or_use_generic( | |
| 61 | tcx: TyCtxt<'_>, | |
| 62 | diag: &mut Diag<'_>, | |
| 63 | impl_def_id: LocalDefId, | |
| 64 | param: &GenericParamDef, | |
| 65 | is_lifetime: bool, | |
| 66 | ) { | |
| 67 | let node = tcx.hir_node_by_def_id(impl_def_id); | |
| 68 | let hir_impl = node.expect_item().expect_impl(); | |
| 69 | ||
| 70 | let Some((index, _)) = hir_impl | |
| 71 | .generics | |
| 72 | .params | |
| 73 | .iter() | |
| 74 | .enumerate() | |
| 75 | .find(|(_, par)| par.def_id.to_def_id() == param.def_id) | |
| 76 | else { | |
| 77 | return; | |
| 78 | }; | |
| 79 | ||
| 80 | // Get the Struct/ADT definition ID from the self type | |
| 81 | let struct_def_id = if let TyKind::Path(QPath::Resolved(_, path)) = hir_impl.self_ty.kind | |
| 82 | && let Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, def_id) = path.res | |
| 83 | { | |
| 84 | def_id | |
| 85 | } else { | |
| 86 | return; | |
| 87 | }; | |
| 88 | ||
| 89 | // Count how many generic parameters are defined in the struct definition | |
| 90 | let generics = tcx.generics_of(struct_def_id); | |
| 91 | let total_params = generics | |
| 92 | .own_params | |
| 93 | .iter() | |
| 94 | .filter(|p| { | |
| 95 | if is_lifetime { | |
| 96 | matches!(p.kind, GenericParamDefKind::Lifetime) | |
| 97 | } else { | |
| 98 | matches!(p.kind, GenericParamDefKind::Type { .. }) | |
| 99 | } | |
| 100 | }) | |
| 101 | .count(); | |
| 102 | ||
| 103 | // Count how many arguments are currently provided in the impl | |
| 104 | let mut provided_params = 0; | |
| 105 | let mut last_segment_args = None; | |
| 106 | ||
| 107 | if let TyKind::Path(QPath::Resolved(_, path)) = hir_impl.self_ty.kind | |
| 108 | && let Some(seg) = path.segments.last() | |
| 109 | && let Some(args) = seg.args | |
| 110 | { | |
| 111 | last_segment_args = Some(args); | |
| 112 | provided_params = args | |
| 113 | .args | |
| 114 | .iter() | |
| 115 | .filter(|arg| match arg { | |
| 116 | GenericArg::Lifetime(_) => is_lifetime, | |
| 117 | GenericArg::Type(_) => !is_lifetime, | |
| 118 | _ => false, | |
| 119 | }) | |
| 120 | .count(); | |
| 121 | } | |
| 122 | ||
| 123 | let mut visitor = ParamUsageVisitor { tcx, param_def_id: param.def_id, found: false }; | |
| 124 | for item_ref in hir_impl.items { | |
| 125 | let _ = visitor.visit_impl_item_ref(item_ref); | |
| 126 | if visitor.found { | |
| 127 | break; | |
| 128 | } | |
| 129 | } | |
| 130 | let is_param_used = visitor.found; | |
| 131 | ||
| 132 | let mut suggestions = vec![]; | |
| 133 | ||
| 134 | // Option A: Remove (Only if not used in body) | |
| 135 | if !is_param_used { | |
| 136 | suggestions.push((hir_impl.generics.span_for_param_removal(index), String::new())); | |
| 137 | } | |
| 138 | ||
| 139 | // Option B: Suggest adding only if there's an available parameter in the struct definition | |
| 140 | // or the parameter is already used somewhere, then we suggest adding to the impl struct and the struct definition | |
| 141 | if provided_params < total_params || is_param_used { | |
| 142 | if let Some(args) = last_segment_args { | |
| 143 | // Struct already has <...>, append to it | |
| 144 | suggestions.push((args.span().unwrap().shrink_to_hi(), format!(", {}", param.name))); | |
| 145 | } else if let TyKind::Path(QPath::Resolved(_, path)) = hir_impl.self_ty.kind { | |
| 146 | // Struct has no <...> yet, add it | |
| 147 | let seg = path.segments.last().unwrap(); | |
| 148 | suggestions.push((seg.ident.span.shrink_to_hi(), format!("<{}>", param.name))); | |
| 149 | } | |
| 150 | if is_param_used { | |
| 151 | // If the parameter is used in the body, we also want to suggest adding it to the struct definition if it's not already there | |
| 152 | let struct_span = tcx.def_span(struct_def_id); | |
| 153 | let last_param_span = if let Some(local_def_id) = struct_def_id.as_local() { | |
| 154 | let hir_struct = tcx.hir_node_by_def_id(local_def_id).expect_item().expect_struct(); | |
| 155 | hir_struct.1.params.last().map(|param| param.span) | |
| 156 | } else { | |
| 157 | let generics = tcx.generics_of(struct_def_id); | |
| 158 | generics.own_params.last().map(|param| tcx.def_span(param.def_id)) | |
| 159 | }; | |
| 160 | ||
| 161 | if let Some(last_param_span) = last_param_span { | |
| 162 | suggestions.push((last_param_span.shrink_to_hi(), format!(", {}", param.name))); | |
| 163 | } else { | |
| 164 | suggestions.push((struct_span.shrink_to_hi(), format!("<{}>", param.name))); | |
| 165 | } | |
| 166 | } | |
| 167 | } | |
| 168 | ||
| 169 | if suggestions.is_empty() { | |
| 170 | return; | |
| 171 | } | |
| 172 | ||
| 173 | let parameter_type = if is_lifetime { "lifetime" } else { "type" }; | |
| 174 | if is_param_used { | |
| 175 | let msg = format!( | |
| 176 | "use the {} parameter `{}` in the `{}` type and use it in the type definition", | |
| 177 | parameter_type, | |
| 178 | param.name, | |
| 179 | tcx.def_path_str(struct_def_id) | |
| 180 | ); | |
| 181 | diag.multipart_suggestion( | |
| 182 | msg, | |
| 183 | vec![ | |
| 184 | (suggestions[0].0, suggestions[0].1.clone()), | |
| 185 | (suggestions[1].0, suggestions[1].1.clone()), | |
| 186 | ], | |
| 187 | Applicability::MaybeIncorrect, | |
| 188 | ); | |
| 189 | } else { | |
| 190 | let msg = if suggestions.len() == 2 { | |
| 191 | format!("either remove the unused {} parameter `{}`", parameter_type, param.name) | |
| 192 | } else { | |
| 193 | format!("remove the unused {} parameter `{}`", parameter_type, param.name) | |
| 194 | }; | |
| 195 | diag.span_suggestion( | |
| 196 | suggestions[0].0, | |
| 197 | msg, | |
| 198 | suggestions[0].1.clone(), | |
| 199 | Applicability::MaybeIncorrect, | |
| 200 | ); | |
| 201 | if suggestions.len() == 2 { | |
| 202 | let msg = format!("or use it"); | |
| 203 | diag.span_suggestion( | |
| 204 | suggestions[1].0, | |
| 205 | msg, | |
| 206 | suggestions[1].1.clone(), | |
| 207 | Applicability::MaybeIncorrect, | |
| 208 | ); | |
| 209 | } | |
| 210 | }; | |
| 211 | } |
compiler/rustc_hir_analysis/src/impl_wf_check.rs+3| ... | ... | @@ -21,6 +21,7 @@ use rustc_span::{ErrorGuaranteed, kw}; |
| 21 | 21 | |
| 22 | 22 | use crate::constrained_generic_params as cgp; |
| 23 | 23 | use crate::errors::UnconstrainedGenericParameter; |
| 24 | use crate::errors::remove_or_use_generic::suggest_to_remove_or_use_generic; | |
| 24 | 25 | |
| 25 | 26 | mod min_specialization; |
| 26 | 27 | |
| ... | ... | @@ -177,6 +178,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained( |
| 177 | 178 | ); |
| 178 | 179 | } |
| 179 | 180 | } |
| 181 | suggest_to_remove_or_use_generic(tcx, &mut diag, impl_def_id, param, true); | |
| 180 | 182 | res = Err(diag.emit()); |
| 181 | 183 | } |
| 182 | 184 | } |
| ... | ... | @@ -242,6 +244,7 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained( |
| 242 | 244 | const_param_note2: const_param_note, |
| 243 | 245 | }); |
| 244 | 246 | diag.code(E0207); |
| 247 | suggest_to_remove_or_use_generic(tcx, &mut diag, impl_def_id, &param, false); | |
| 245 | 248 | res = Err(diag.emit()); |
| 246 | 249 | } |
| 247 | 250 | } |
compiler/rustc_mir_transform/src/elaborate_drop.rs+103-165| ... | ... | @@ -207,6 +207,7 @@ where |
| 207 | 207 | // We keep async drop unexpanded to poll-loop here, to expand it later, at StateTransform - |
| 208 | 208 | // into states expand. |
| 209 | 209 | // call_destructor_only - to call only AsyncDrop::drop, not full async_drop_in_place glue |
| 210 | #[instrument(level = "debug", skip(self), ret)] | |
| 210 | 211 | fn build_async_drop( |
| 211 | 212 | &mut self, |
| 212 | 213 | place: Place<'tcx>, |
| ... | ... | @@ -221,14 +222,8 @@ where |
| 221 | 222 | let span = self.source_info.span; |
| 222 | 223 | |
| 223 | 224 | let pin_obj_bb = bb.unwrap_or_else(|| { |
| 224 | self.elaborator.patch().new_block(BasicBlockData::new( | |
| 225 | Some(Terminator { | |
| 226 | // Temporary terminator, will be replaced by patch | |
| 227 | source_info: self.source_info, | |
| 228 | kind: TerminatorKind::Return, | |
| 229 | }), | |
| 230 | false, | |
| 231 | )) | |
| 225 | // Temporary terminator, will be replaced by patch | |
| 226 | self.new_block(unwind, TerminatorKind::Return) | |
| 232 | 227 | }); |
| 233 | 228 | |
| 234 | 229 | let (fut_ty, drop_fn_def_id, trait_args) = if call_destructor_only { |
| ... | ... | @@ -565,6 +560,7 @@ where |
| 565 | 560 | .collect() |
| 566 | 561 | } |
| 567 | 562 | |
| 563 | #[instrument(level = "debug", skip(self), ret)] | |
| 568 | 564 | fn drop_subpath( |
| 569 | 565 | &mut self, |
| 570 | 566 | place: Place<'tcx>, |
| ... | ... | @@ -574,8 +570,6 @@ where |
| 574 | 570 | dropline: Option<BasicBlock>, |
| 575 | 571 | ) -> BasicBlock { |
| 576 | 572 | if let Some(path) = path { |
| 577 | debug!("drop_subpath: for std field {:?}", place); | |
| 578 | ||
| 579 | 573 | DropCtxt { |
| 580 | 574 | elaborator: self.elaborator, |
| 581 | 575 | source_info: self.source_info, |
| ... | ... | @@ -587,8 +581,6 @@ where |
| 587 | 581 | } |
| 588 | 582 | .elaborated_drop_block() |
| 589 | 583 | } else { |
| 590 | debug!("drop_subpath: for rest field {:?}", place); | |
| 591 | ||
| 592 | 584 | DropCtxt { |
| 593 | 585 | elaborator: self.elaborator, |
| 594 | 586 | source_info: self.source_info, |
| ... | ... | @@ -596,8 +588,7 @@ where |
| 596 | 588 | succ, |
| 597 | 589 | unwind, |
| 598 | 590 | dropline, |
| 599 | // Using `self.path` here to condition the drop on | |
| 600 | // our own drop flag. | |
| 591 | // Using `self.path` here to condition the drop on our own drop flag. | |
| 601 | 592 | path: self.path, |
| 602 | 593 | } |
| 603 | 594 | .complete_drop(succ, unwind) |
| ... | ... | @@ -614,6 +605,7 @@ where |
| 614 | 605 | /// `dropline_ladder` is a similar list of steps in reverse order, |
| 615 | 606 | /// which is called if the matching step of the drop glue will contain async drop |
| 616 | 607 | /// (expanded later to Yield) and the containing coroutine will be dropped at this point. |
| 608 | #[instrument(level = "debug", skip(self), ret)] | |
| 617 | 609 | fn drop_halfladder( |
| 618 | 610 | &mut self, |
| 619 | 611 | unwind_ladder: &[Unwind], |
| ... | ... | @@ -679,6 +671,7 @@ where |
| 679 | 671 | /// |
| 680 | 672 | /// NOTE: this does not clear the master drop flag, so you need |
| 681 | 673 | /// to point succ/unwind on a `drop_ladder_bottom`. |
| 674 | #[instrument(level = "debug", skip(self), ret)] | |
| 682 | 675 | fn drop_ladder( |
| 683 | 676 | &mut self, |
| 684 | 677 | fields: Vec<(Place<'tcx>, Option<D::Path>)>, |
| ... | ... | @@ -686,7 +679,6 @@ where |
| 686 | 679 | unwind: Unwind, |
| 687 | 680 | dropline: Option<BasicBlock>, |
| 688 | 681 | ) -> (BasicBlock, Unwind, Option<BasicBlock>) { |
| 689 | debug!("drop_ladder({:?}, {:?})", self, fields); | |
| 690 | 682 | assert!( |
| 691 | 683 | if unwind.is_cleanup() { dropline.is_none() } else { true }, |
| 692 | 684 | "Dropline is set for cleanup drop ladder" |
| ... | ... | @@ -723,9 +715,8 @@ where |
| 723 | 715 | ) |
| 724 | 716 | } |
| 725 | 717 | |
| 718 | #[instrument(level = "debug", skip(self), ret)] | |
| 726 | 719 | fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock { |
| 727 | debug!("open_drop_for_tuple({:?}, {:?})", self, tys); | |
| 728 | ||
| 729 | 720 | let fields = tys |
| 730 | 721 | .iter() |
| 731 | 722 | .enumerate() |
| ... | ... | @@ -769,18 +760,14 @@ where |
| 769 | 760 | |
| 770 | 761 | let do_drop_bb = self.drop_subpath(interior, interior_path, succ, unwind, dropline); |
| 771 | 762 | |
| 772 | let setup_bbd = BasicBlockData::new_stmts( | |
| 763 | self.new_block_with_statements( | |
| 764 | unwind, | |
| 773 | 765 | vec![self.assign( |
| 774 | 766 | Place::from(ptr_local), |
| 775 | 767 | Rvalue::Cast(CastKind::Transmute, Operand::Copy(nonnull_place), ptr_ty), |
| 776 | 768 | )], |
| 777 | Some(Terminator { | |
| 778 | kind: TerminatorKind::Goto { target: do_drop_bb }, | |
| 779 | source_info: self.source_info, | |
| 780 | }), | |
| 781 | unwind.is_cleanup(), | |
| 782 | ); | |
| 783 | self.elaborator.patch().new_block(setup_bbd) | |
| 769 | TerminatorKind::Goto { target: do_drop_bb }, | |
| 770 | ) | |
| 784 | 771 | } |
| 785 | 772 | |
| 786 | 773 | #[instrument(level = "debug", ret)] |
| ... | ... | @@ -790,17 +777,11 @@ where |
| 790 | 777 | args: GenericArgsRef<'tcx>, |
| 791 | 778 | ) -> BasicBlock { |
| 792 | 779 | if adt.variants().is_empty() { |
| 793 | return self.elaborator.patch().new_block(BasicBlockData::new( | |
| 794 | Some(Terminator { | |
| 795 | source_info: self.source_info, | |
| 796 | kind: TerminatorKind::Unreachable, | |
| 797 | }), | |
| 798 | self.unwind.is_cleanup(), | |
| 799 | )); | |
| 780 | return self.new_block(self.unwind, TerminatorKind::Unreachable); | |
| 800 | 781 | } |
| 801 | 782 | |
| 802 | 783 | let skip_contents = adt.is_union() || adt.is_manually_drop(); |
| 803 | let contents_drop = if skip_contents { | |
| 784 | let (contents_succ, contents_unwind, contents_dropline) = if skip_contents { | |
| 804 | 785 | if adt.has_dtor(self.tcx()) && self.elaborator.get_drop_flag(self.path).is_some() { |
| 805 | 786 | // the top-level drop flag is usually cleared by open_drop_for_adt_contents |
| 806 | 787 | // types with destructors would still need an empty drop ladder to clear it |
| ... | ... | @@ -819,21 +800,19 @@ where |
| 819 | 800 | if adt.has_dtor(self.tcx()) { |
| 820 | 801 | let destructor_block = if adt.is_box() { |
| 821 | 802 | // we need to drop the inside of the box before running the destructor |
| 822 | let succ = self.destructor_call_block_sync((contents_drop.0, contents_drop.1)); | |
| 823 | let unwind = contents_drop | |
| 824 | .1 | |
| 825 | .map(|unwind| self.destructor_call_block_sync((unwind, Unwind::InCleanup))); | |
| 826 | let dropline = contents_drop | |
| 827 | .2 | |
| 828 | .map(|dropline| self.destructor_call_block_sync((dropline, contents_drop.1))); | |
| 803 | let succ = self.destructor_call_block_sync(contents_succ, contents_unwind); | |
| 804 | let unwind = contents_unwind | |
| 805 | .map(|unwind| self.destructor_call_block_sync(unwind, Unwind::InCleanup)); | |
| 806 | let dropline = contents_dropline | |
| 807 | .map(|dropline| self.destructor_call_block_sync(dropline, contents_unwind)); | |
| 829 | 808 | self.open_drop_for_box_contents(adt, args, succ, unwind, dropline) |
| 830 | 809 | } else { |
| 831 | self.destructor_call_block(contents_drop) | |
| 810 | self.destructor_call_block(contents_succ, contents_unwind, contents_dropline) | |
| 832 | 811 | }; |
| 833 | 812 | |
| 834 | self.drop_flag_test_block(destructor_block, contents_drop.0, contents_drop.1) | |
| 813 | self.drop_flag_test_block(destructor_block, contents_succ, contents_unwind) | |
| 835 | 814 | } else { |
| 836 | contents_drop.0 | |
| 815 | contents_succ | |
| 837 | 816 | } |
| 838 | 817 | } |
| 839 | 818 | |
| ... | ... | @@ -976,26 +955,22 @@ where |
| 976 | 955 | let discr_ty = adt.repr().discr_type().to_ty(self.tcx()); |
| 977 | 956 | let discr = Place::from(self.new_temp(discr_ty)); |
| 978 | 957 | let discr_rv = Rvalue::Discriminant(self.place); |
| 979 | let switch_block = BasicBlockData::new_stmts( | |
| 958 | let switch_block = self.new_block_with_statements( | |
| 959 | unwind, | |
| 980 | 960 | vec![self.assign(discr, discr_rv)], |
| 981 | Some(Terminator { | |
| 982 | source_info: self.source_info, | |
| 983 | kind: TerminatorKind::SwitchInt { | |
| 984 | discr: Operand::Move(discr), | |
| 985 | targets: SwitchTargets::new( | |
| 986 | values.iter().copied().zip(blocks.iter().copied()), | |
| 987 | *blocks.last().unwrap(), | |
| 988 | ), | |
| 989 | }, | |
| 990 | }), | |
| 991 | unwind.is_cleanup(), | |
| 961 | TerminatorKind::SwitchInt { | |
| 962 | discr: Operand::Move(discr), | |
| 963 | targets: SwitchTargets::new( | |
| 964 | values.iter().copied().zip(blocks.iter().copied()), | |
| 965 | *blocks.last().unwrap(), | |
| 966 | ), | |
| 967 | }, | |
| 992 | 968 | ); |
| 993 | let switch_block = self.elaborator.patch().new_block(switch_block); | |
| 994 | 969 | self.drop_flag_test_block(switch_block, succ, unwind) |
| 995 | 970 | } |
| 996 | 971 | |
| 997 | fn destructor_call_block_sync(&mut self, (succ, unwind): (BasicBlock, Unwind)) -> BasicBlock { | |
| 998 | debug!("destructor_call_block_sync({:?}, {:?})", self, succ); | |
| 972 | #[instrument(level = "debug", skip(self), ret)] | |
| 973 | fn destructor_call_block_sync(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock { | |
| 999 | 974 | let tcx = self.tcx(); |
| 1000 | 975 | let drop_trait = tcx.require_lang_item(LangItem::Drop, DUMMY_SP); |
| 1001 | 976 | let drop_fn = tcx.associated_item_def_ids(drop_trait)[0]; |
| ... | ... | @@ -1005,7 +980,8 @@ where |
| 1005 | 980 | let ref_place = self.new_temp(ref_ty); |
| 1006 | 981 | let unit_temp = Place::from(self.new_temp(tcx.types.unit)); |
| 1007 | 982 | |
| 1008 | let result = BasicBlockData::new_stmts( | |
| 983 | self.new_block_with_statements( | |
| 984 | unwind, | |
| 1009 | 985 | vec![self.assign( |
| 1010 | 986 | Place::from(ref_place), |
| 1011 | 987 | Rvalue::Ref( |
| ... | ... | @@ -1014,40 +990,31 @@ where |
| 1014 | 990 | self.place, |
| 1015 | 991 | ), |
| 1016 | 992 | )], |
| 1017 | Some(Terminator { | |
| 1018 | kind: TerminatorKind::Call { | |
| 1019 | func: Operand::function_handle( | |
| 1020 | tcx, | |
| 1021 | drop_fn, | |
| 1022 | [ty.into()], | |
| 1023 | self.source_info.span, | |
| 1024 | ), | |
| 1025 | args: [Spanned { node: Operand::Move(Place::from(ref_place)), span: DUMMY_SP }] | |
| 1026 | .into(), | |
| 1027 | destination: unit_temp, | |
| 1028 | target: Some(succ), | |
| 1029 | unwind: unwind.into_action(), | |
| 1030 | call_source: CallSource::Misc, | |
| 1031 | fn_span: self.source_info.span, | |
| 1032 | }, | |
| 1033 | source_info: self.source_info, | |
| 1034 | }), | |
| 1035 | unwind.is_cleanup(), | |
| 1036 | ); | |
| 1037 | ||
| 1038 | self.elaborator.patch().new_block(result) | |
| 993 | TerminatorKind::Call { | |
| 994 | func: Operand::function_handle(tcx, drop_fn, [ty.into()], self.source_info.span), | |
| 995 | args: [Spanned { node: Operand::Move(Place::from(ref_place)), span: DUMMY_SP }] | |
| 996 | .into(), | |
| 997 | destination: unit_temp, | |
| 998 | target: Some(succ), | |
| 999 | unwind: unwind.into_action(), | |
| 1000 | call_source: CallSource::Misc, | |
| 1001 | fn_span: self.source_info.span, | |
| 1002 | }, | |
| 1003 | ) | |
| 1039 | 1004 | } |
| 1040 | 1005 | |
| 1006 | #[instrument(level = "debug", skip(self), ret)] | |
| 1041 | 1007 | fn destructor_call_block( |
| 1042 | 1008 | &mut self, |
| 1043 | (succ, unwind, dropline): (BasicBlock, Unwind, Option<BasicBlock>), | |
| 1009 | succ: BasicBlock, | |
| 1010 | unwind: Unwind, | |
| 1011 | dropline: Option<BasicBlock>, | |
| 1044 | 1012 | ) -> BasicBlock { |
| 1045 | debug!("destructor_call_block({:?}, {:?})", self, succ); | |
| 1046 | 1013 | let ty = self.place_ty(self.place); |
| 1047 | 1014 | if !unwind.is_cleanup() && self.check_if_can_async_drop(ty, true) { |
| 1048 | 1015 | self.build_async_drop(self.place, ty, None, succ, unwind, dropline, true) |
| 1049 | 1016 | } else { |
| 1050 | self.destructor_call_block_sync((succ, unwind)) | |
| 1017 | self.destructor_call_block_sync(succ, unwind) | |
| 1051 | 1018 | } |
| 1052 | 1019 | } |
| 1053 | 1020 | |
| ... | ... | @@ -1080,7 +1047,8 @@ where |
| 1080 | 1047 | let can_go = Place::from(self.new_temp(tcx.types.bool)); |
| 1081 | 1048 | let one = self.constant_usize(1); |
| 1082 | 1049 | |
| 1083 | let drop_block = BasicBlockData::new_stmts( | |
| 1050 | let drop_block = self.new_block_with_statements( | |
| 1051 | unwind, | |
| 1084 | 1052 | vec![ |
| 1085 | 1053 | self.assign( |
| 1086 | 1054 | ptr, |
| ... | ... | @@ -1091,27 +1059,18 @@ where |
| 1091 | 1059 | Rvalue::BinaryOp(BinOp::Add, Box::new((move_(cur.into()), one))), |
| 1092 | 1060 | ), |
| 1093 | 1061 | ], |
| 1094 | Some(Terminator { | |
| 1095 | source_info: self.source_info, | |
| 1096 | // this gets overwritten by drop elaboration. | |
| 1097 | kind: TerminatorKind::Unreachable, | |
| 1098 | }), | |
| 1099 | unwind.is_cleanup(), | |
| 1062 | // this gets overwritten by drop elaboration. | |
| 1063 | TerminatorKind::Unreachable, | |
| 1100 | 1064 | ); |
| 1101 | let drop_block = self.elaborator.patch().new_block(drop_block); | |
| 1102 | 1065 | |
| 1103 | let loop_block = BasicBlockData::new_stmts( | |
| 1066 | let loop_block = self.new_block_with_statements( | |
| 1067 | unwind, | |
| 1104 | 1068 | vec![self.assign( |
| 1105 | 1069 | can_go, |
| 1106 | 1070 | Rvalue::BinaryOp(BinOp::Eq, Box::new((copy(Place::from(cur)), copy(len.into())))), |
| 1107 | 1071 | )], |
| 1108 | Some(Terminator { | |
| 1109 | source_info: self.source_info, | |
| 1110 | kind: TerminatorKind::if_(move_(can_go), succ, drop_block), | |
| 1111 | }), | |
| 1112 | unwind.is_cleanup(), | |
| 1072 | TerminatorKind::if_(move_(can_go), succ, drop_block), | |
| 1113 | 1073 | ); |
| 1114 | let loop_block = self.elaborator.patch().new_block(loop_block); | |
| 1115 | 1074 | |
| 1116 | 1075 | let place = tcx.mk_place_deref(ptr); |
| 1117 | 1076 | if !unwind.is_cleanup() && self.check_if_can_async_drop(ety, false) { |
| ... | ... | @@ -1140,13 +1099,13 @@ where |
| 1140 | 1099 | loop_block |
| 1141 | 1100 | } |
| 1142 | 1101 | |
| 1102 | #[instrument(level = "debug", skip(self), ret)] | |
| 1143 | 1103 | fn open_drop_for_array( |
| 1144 | 1104 | &mut self, |
| 1145 | 1105 | array_ty: Ty<'tcx>, |
| 1146 | 1106 | ety: Ty<'tcx>, |
| 1147 | 1107 | opt_size: Option<u64>, |
| 1148 | 1108 | ) -> BasicBlock { |
| 1149 | debug!("open_drop_for_array({:?}, {:?}, {:?})", array_ty, ety, opt_size); | |
| 1150 | 1109 | let tcx = self.tcx(); |
| 1151 | 1110 | |
| 1152 | 1111 | if let Some(size) = opt_size { |
| ... | ... | @@ -1215,7 +1174,15 @@ where |
| 1215 | 1174 | let slice_ptr_ty = Ty::new_mut_ptr(tcx, slice_ty); |
| 1216 | 1175 | let slice_ptr = self.new_temp(slice_ptr_ty); |
| 1217 | 1176 | |
| 1218 | let mut delegate_block = BasicBlockData::new_stmts( | |
| 1177 | let array_place = mem::replace( | |
| 1178 | &mut self.place, | |
| 1179 | Place::from(slice_ptr).project_deeper(&[PlaceElem::Deref], tcx), | |
| 1180 | ); | |
| 1181 | let slice_block = self.drop_loop_trio_for_slice(ety); | |
| 1182 | self.place = array_place; | |
| 1183 | ||
| 1184 | self.new_block_with_statements( | |
| 1185 | self.unwind, | |
| 1219 | 1186 | vec![ |
| 1220 | 1187 | self.assign(Place::from(array_ptr), Rvalue::RawPtr(RawPtrKind::Mut, self.place)), |
| 1221 | 1188 | self.assign( |
| ... | ... | @@ -1230,28 +1197,14 @@ where |
| 1230 | 1197 | ), |
| 1231 | 1198 | ), |
| 1232 | 1199 | ], |
| 1233 | None, | |
| 1234 | self.unwind.is_cleanup(), | |
| 1235 | ); | |
| 1236 | ||
| 1237 | let array_place = mem::replace( | |
| 1238 | &mut self.place, | |
| 1239 | Place::from(slice_ptr).project_deeper(&[PlaceElem::Deref], tcx), | |
| 1240 | ); | |
| 1241 | let slice_block = self.drop_loop_trio_for_slice(ety); | |
| 1242 | self.place = array_place; | |
| 1243 | ||
| 1244 | delegate_block.terminator = Some(Terminator { | |
| 1245 | source_info: self.source_info, | |
| 1246 | kind: TerminatorKind::Goto { target: slice_block }, | |
| 1247 | }); | |
| 1248 | self.elaborator.patch().new_block(delegate_block) | |
| 1200 | TerminatorKind::Goto { target: slice_block }, | |
| 1201 | ) | |
| 1249 | 1202 | } |
| 1250 | 1203 | |
| 1251 | 1204 | /// Creates a trio of drop-loops of `place`, which drops its contents, even |
| 1252 | 1205 | /// in the case of 1 panic or in the case of coroutine drop |
| 1206 | #[instrument(level = "debug", skip(self), ret)] | |
| 1253 | 1207 | fn drop_loop_trio_for_slice(&mut self, ety: Ty<'tcx>) -> BasicBlock { |
| 1254 | debug!("drop_loop_trio_for_slice({:?})", ety); | |
| 1255 | 1208 | let tcx = self.tcx(); |
| 1256 | 1209 | let len = self.new_temp(tcx.types.usize); |
| 1257 | 1210 | let cur = self.new_temp(tcx.types.usize); |
| ... | ... | @@ -1274,7 +1227,8 @@ where |
| 1274 | 1227 | }; |
| 1275 | 1228 | |
| 1276 | 1229 | let zero = self.constant_usize(0); |
| 1277 | let block = BasicBlockData::new_stmts( | |
| 1230 | let drop_block = self.new_block_with_statements( | |
| 1231 | unwind, | |
| 1278 | 1232 | vec![ |
| 1279 | 1233 | self.assign( |
| 1280 | 1234 | len.into(), |
| ... | ... | @@ -1285,14 +1239,9 @@ where |
| 1285 | 1239 | ), |
| 1286 | 1240 | self.assign(cur.into(), Rvalue::Use(zero, WithRetag::Yes)), |
| 1287 | 1241 | ], |
| 1288 | Some(Terminator { | |
| 1289 | source_info: self.source_info, | |
| 1290 | kind: TerminatorKind::Goto { target: loop_block }, | |
| 1291 | }), | |
| 1292 | unwind.is_cleanup(), | |
| 1242 | TerminatorKind::Goto { target: loop_block }, | |
| 1293 | 1243 | ); |
| 1294 | 1244 | |
| 1295 | let drop_block = self.elaborator.patch().new_block(block); | |
| 1296 | 1245 | // FIXME(#34708): handle partially-dropped array/slice elements. |
| 1297 | 1246 | let reset_block = self.drop_flag_reset_block(DropFlagMode::Deep, drop_block, unwind); |
| 1298 | 1247 | self.drop_flag_test_block(reset_block, self.succ, unwind) |
| ... | ... | @@ -1336,37 +1285,28 @@ where |
| 1336 | 1285 | self.source_info.span, |
| 1337 | 1286 | "open drop for unsafe binder shouldn't be encountered", |
| 1338 | 1287 | ); |
| 1339 | self.elaborator.patch().new_block(BasicBlockData::new( | |
| 1340 | Some(Terminator { | |
| 1341 | source_info: self.source_info, | |
| 1342 | kind: TerminatorKind::Unreachable, | |
| 1343 | }), | |
| 1344 | self.unwind.is_cleanup(), | |
| 1345 | )) | |
| 1288 | self.new_block(self.unwind, TerminatorKind::Unreachable) | |
| 1346 | 1289 | } |
| 1347 | 1290 | |
| 1348 | 1291 | _ => span_bug!(self.source_info.span, "open drop from non-ADT `{:?}`", ty), |
| 1349 | 1292 | } |
| 1350 | 1293 | } |
| 1351 | 1294 | |
| 1295 | #[instrument(level = "debug", skip(self), ret)] | |
| 1352 | 1296 | fn complete_drop(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock { |
| 1353 | debug!("complete_drop(succ={:?}, unwind={:?})", succ, unwind); | |
| 1354 | ||
| 1355 | 1297 | let drop_block = self.drop_block(succ, unwind); |
| 1356 | ||
| 1357 | 1298 | self.drop_flag_test_block(drop_block, succ, unwind) |
| 1358 | 1299 | } |
| 1359 | 1300 | |
| 1360 | 1301 | /// Creates a block that resets the drop flag. If `mode` is deep, all children drop flags will |
| 1361 | 1302 | /// also be cleared. |
| 1303 | #[instrument(level = "debug", skip(self), ret)] | |
| 1362 | 1304 | fn drop_flag_reset_block( |
| 1363 | 1305 | &mut self, |
| 1364 | 1306 | mode: DropFlagMode, |
| 1365 | 1307 | succ: BasicBlock, |
| 1366 | 1308 | unwind: Unwind, |
| 1367 | 1309 | ) -> BasicBlock { |
| 1368 | debug!("drop_flag_reset_block({:?},{:?})", self, mode); | |
| 1369 | ||
| 1370 | 1310 | if unwind.is_cleanup() { |
| 1371 | 1311 | // The drop flag isn't read again on the unwind path, so don't |
| 1372 | 1312 | // bother setting it. |
| ... | ... | @@ -1378,25 +1318,23 @@ where |
| 1378 | 1318 | block |
| 1379 | 1319 | } |
| 1380 | 1320 | |
| 1321 | #[instrument(level = "debug", skip(self), ret)] | |
| 1381 | 1322 | fn elaborated_drop_block(&mut self) -> BasicBlock { |
| 1382 | debug!("elaborated_drop_block({:?})", self); | |
| 1383 | let blk = self.drop_block_simple(self.succ, self.unwind); | |
| 1323 | let blk = self.new_block( | |
| 1324 | self.unwind, | |
| 1325 | TerminatorKind::Drop { | |
| 1326 | place: self.place, | |
| 1327 | target: self.succ, | |
| 1328 | unwind: self.unwind.into_action(), | |
| 1329 | replace: false, | |
| 1330 | drop: self.dropline, | |
| 1331 | async_fut: None, | |
| 1332 | }, | |
| 1333 | ); | |
| 1384 | 1334 | self.elaborate_drop(blk); |
| 1385 | 1335 | blk |
| 1386 | 1336 | } |
| 1387 | 1337 | |
| 1388 | fn drop_block_simple(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { | |
| 1389 | let block = TerminatorKind::Drop { | |
| 1390 | place: self.place, | |
| 1391 | target, | |
| 1392 | unwind: unwind.into_action(), | |
| 1393 | replace: false, | |
| 1394 | drop: self.dropline, | |
| 1395 | async_fut: None, | |
| 1396 | }; | |
| 1397 | self.new_block(unwind, block) | |
| 1398 | } | |
| 1399 | ||
| 1400 | 1338 | fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { |
| 1401 | 1339 | let drop_ty = self.place_ty(self.place); |
| 1402 | 1340 | if !unwind.is_cleanup() && self.check_if_can_async_drop(drop_ty, false) { |
| ... | ... | @@ -1410,15 +1348,17 @@ where |
| 1410 | 1348 | false, |
| 1411 | 1349 | ) |
| 1412 | 1350 | } else { |
| 1413 | let block = TerminatorKind::Drop { | |
| 1414 | place: self.place, | |
| 1415 | target, | |
| 1416 | unwind: unwind.into_action(), | |
| 1417 | replace: false, | |
| 1418 | drop: None, | |
| 1419 | async_fut: None, | |
| 1420 | }; | |
| 1421 | self.new_block(unwind, block) | |
| 1351 | self.new_block( | |
| 1352 | unwind, | |
| 1353 | TerminatorKind::Drop { | |
| 1354 | place: self.place, | |
| 1355 | target, | |
| 1356 | unwind: unwind.into_action(), | |
| 1357 | replace: false, | |
| 1358 | drop: None, | |
| 1359 | async_fut: None, | |
| 1360 | }, | |
| 1361 | ) | |
| 1422 | 1362 | } |
| 1423 | 1363 | } |
| 1424 | 1364 | |
| ... | ... | @@ -1432,6 +1372,7 @@ where |
| 1432 | 1372 | /// Depending on the required `DropStyle`, this might be a generated block with an `if` |
| 1433 | 1373 | /// terminator (for dynamic/open drops), or it might be `on_set` or `on_unset` itself, in case |
| 1434 | 1374 | /// the drop can be statically determined. |
| 1375 | #[instrument(level = "debug", skip(self), ret)] | |
| 1435 | 1376 | fn drop_flag_test_block( |
| 1436 | 1377 | &mut self, |
| 1437 | 1378 | on_set: BasicBlock, |
| ... | ... | @@ -1439,11 +1380,6 @@ where |
| 1439 | 1380 | unwind: Unwind, |
| 1440 | 1381 | ) -> BasicBlock { |
| 1441 | 1382 | let style = self.elaborator.drop_style(self.path, DropFlagMode::Shallow); |
| 1442 | debug!( | |
| 1443 | "drop_flag_test_block({:?},{:?},{:?},{:?}) - {:?}", | |
| 1444 | self, on_set, on_unset, unwind, style | |
| 1445 | ); | |
| 1446 | ||
| 1447 | 1383 | match style { |
| 1448 | 1384 | DropStyle::Dead => on_unset, |
| 1449 | 1385 | DropStyle::Static => on_set, |
| ... | ... | @@ -1455,6 +1391,7 @@ where |
| 1455 | 1391 | } |
| 1456 | 1392 | } |
| 1457 | 1393 | |
| 1394 | #[instrument(level = "trace", skip(self), ret)] | |
| 1458 | 1395 | fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock { |
| 1459 | 1396 | self.elaborator.patch().new_block(BasicBlockData::new( |
| 1460 | 1397 | Some(Terminator { source_info: self.source_info, kind: k }), |
| ... | ... | @@ -1462,6 +1399,7 @@ where |
| 1462 | 1399 | )) |
| 1463 | 1400 | } |
| 1464 | 1401 | |
| 1402 | #[instrument(level = "trace", skip(self, statements), ret)] | |
| 1465 | 1403 | fn new_block_with_statements( |
| 1466 | 1404 | &mut self, |
| 1467 | 1405 | unwind: Unwind, |
compiler/rustc_passes/src/eii.rs+2-2| ... | ... | @@ -18,8 +18,8 @@ enum CheckingMode { |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | fn get_checking_mode(tcx: TyCtxt<'_>) -> CheckingMode { |
| 21 | // if any of the crate types is not rlib or dylib, we must check for existence. | |
| 22 | if tcx.crate_types().iter().any(|i| !matches!(i, CrateType::Rlib | CrateType::Dylib)) { | |
| 21 | // if any of the crate types is not rlib, we must check for existence. | |
| 22 | if tcx.crate_types().iter().any(|i| !matches!(i, CrateType::Rlib)) { | |
| 23 | 23 | CheckingMode::CheckExistence |
| 24 | 24 | } else { |
| 25 | 25 | CheckingMode::CheckDuplicates |
compiler/rustc_resolve/src/late.rs+14-3| ... | ... | @@ -3612,6 +3612,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3612 | 3612 | this.check_trait_item( |
| 3613 | 3613 | item.id, |
| 3614 | 3614 | *ident, |
| 3615 | *ident, | |
| 3615 | 3616 | &item.kind, |
| 3616 | 3617 | ValueNS, |
| 3617 | 3618 | item.span, |
| ... | ... | @@ -3656,7 +3657,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3656 | 3657 | ); |
| 3657 | 3658 | self.resolve_define_opaques(define_opaque); |
| 3658 | 3659 | } |
| 3659 | AssocItemKind::Fn(Fn { ident, generics, define_opaque, .. }) => { | |
| 3660 | AssocItemKind::Fn(fn_kind @ Fn { ident, generics, define_opaque, .. }) => { | |
| 3660 | 3661 | debug!("resolve_implementation AssocItemKind::Fn"); |
| 3661 | 3662 | // We also need a new scope for the impl item type parameters. |
| 3662 | 3663 | self.with_generic_param_rib( |
| ... | ... | @@ -3666,10 +3667,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3666 | 3667 | LifetimeBinderKind::Function, |
| 3667 | 3668 | generics.span, |
| 3668 | 3669 | |this| { |
| 3670 | let effective_ident = if is_in_trait_impl && fn_kind.is_pin_drop_sugar() { | |
| 3671 | Ident::new(sym::pin_drop, ident.span) | |
| 3672 | } else { | |
| 3673 | *ident | |
| 3674 | }; | |
| 3669 | 3675 | // If this is a trait impl, ensure the method |
| 3670 | 3676 | // exists in trait |
| 3671 | 3677 | this.check_trait_item( |
| 3672 | 3678 | item.id, |
| 3679 | effective_ident, | |
| 3673 | 3680 | *ident, |
| 3674 | 3681 | &item.kind, |
| 3675 | 3682 | ValueNS, |
| ... | ... | @@ -3701,6 +3708,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3701 | 3708 | this.check_trait_item( |
| 3702 | 3709 | item.id, |
| 3703 | 3710 | *ident, |
| 3711 | *ident, | |
| 3704 | 3712 | &item.kind, |
| 3705 | 3713 | TypeNS, |
| 3706 | 3714 | item.span, |
| ... | ... | @@ -3726,6 +3734,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3726 | 3734 | this.check_trait_item( |
| 3727 | 3735 | item.id, |
| 3728 | 3736 | delegation.ident, |
| 3737 | delegation.ident, | |
| 3729 | 3738 | &item.kind, |
| 3730 | 3739 | ValueNS, |
| 3731 | 3740 | item.span, |
| ... | ... | @@ -3750,6 +3759,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3750 | 3759 | &mut self, |
| 3751 | 3760 | id: NodeId, |
| 3752 | 3761 | mut ident: Ident, |
| 3762 | mut reported_ident: Ident, | |
| 3753 | 3763 | kind: &AssocItemKind, |
| 3754 | 3764 | ns: Namespace, |
| 3755 | 3765 | span: Span, |
| ... | ... | @@ -3763,6 +3773,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3763 | 3773 | return; |
| 3764 | 3774 | }; |
| 3765 | 3775 | ident.span.normalize_to_macros_2_0_and_adjust(module.expansion); |
| 3776 | reported_ident.span.normalize_to_macros_2_0_and_adjust(module.expansion); | |
| 3766 | 3777 | let key = BindingKey::new(IdentKey::new(ident), ns); |
| 3767 | 3778 | let mut decl = self.r.resolution(module, key).and_then(|r| r.best_decl()); |
| 3768 | 3779 | debug!(?decl); |
| ... | ... | @@ -3798,10 +3809,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 3798 | 3809 | |
| 3799 | 3810 | let Some(decl) = decl else { |
| 3800 | 3811 | // We could not find the method: report an error. |
| 3801 | let candidate = self.find_similarly_named_assoc_item(ident.name, kind); | |
| 3812 | let candidate = self.find_similarly_named_assoc_item(reported_ident.name, kind); | |
| 3802 | 3813 | let path = &self.current_trait_ref.as_ref().unwrap().1.path; |
| 3803 | 3814 | let path_names = path_names_to_string(path); |
| 3804 | self.report_error(span, err(ident, path_names, candidate)); | |
| 3815 | self.report_error(span, err(reported_ident, path_names, candidate)); | |
| 3805 | 3816 | feed_visibility(self, module.def_id()); |
| 3806 | 3817 | return; |
| 3807 | 3818 | }; |
compiler/rustc_target/src/spec/base/wasm.rs+7| ... | ... | @@ -118,6 +118,13 @@ pub(crate) fn options() -> TargetOptions { |
| 118 | 118 | // with unwinding. |
| 119 | 119 | llvm_args: cvs!["-wasm-use-legacy-eh=false"], |
| 120 | 120 | |
| 121 | // WASI's `sys::args::init` function ignores its arguments; instead, | |
| 122 | // `args::args()` makes the WASI API calls itself. | |
| 123 | // | |
| 124 | // Other Wasm targets make no use of `std::env` entirely. | |
| 125 | // Emscripten enables it explicitly. | |
| 126 | main_needs_argc_argv: false, | |
| 127 | ||
| 121 | 128 | ..Default::default() |
| 122 | 129 | } |
| 123 | 130 | } |
compiler/rustc_target/src/spec/targets/wasm32_unknown_emscripten.rs+1| ... | ... | @@ -28,6 +28,7 @@ pub(crate) fn target() -> Target { |
| 28 | 28 | crt_static_respected: true, |
| 29 | 29 | crt_static_default: true, |
| 30 | 30 | crt_static_allows_dylibs: true, |
| 31 | main_needs_argc_argv: true, | |
| 31 | 32 | panic_strategy: PanicStrategy::Unwind, |
| 32 | 33 | no_default_libraries: false, |
| 33 | 34 | families: cvs!["unix", "wasm"], |
compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs-4| ... | ... | @@ -41,10 +41,6 @@ pub(crate) fn target() -> Target { |
| 41 | 41 | // without a main function. |
| 42 | 42 | options.crt_static_allows_dylibs = true; |
| 43 | 43 | |
| 44 | // WASI's `sys::args::init` function ignores its arguments; instead, | |
| 45 | // `args::args()` makes the WASI API calls itself. | |
| 46 | options.main_needs_argc_argv = false; | |
| 47 | ||
| 48 | 44 | // And, WASI mangles the name of "main" to distinguish between different |
| 49 | 45 | // signatures. |
| 50 | 46 | options.entry_name = "__main_void".into(); |
compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs-4| ... | ... | @@ -52,10 +52,6 @@ pub(crate) fn target() -> Target { |
| 52 | 52 | // without a main function. |
| 53 | 53 | options.crt_static_allows_dylibs = true; |
| 54 | 54 | |
| 55 | // WASI's `sys::args::init` function ignores its arguments; instead, | |
| 56 | // `args::args()` makes the WASI API calls itself. | |
| 57 | options.main_needs_argc_argv = false; | |
| 58 | ||
| 59 | 55 | // And, WASI mangles the name of "main" to distinguish between different |
| 60 | 56 | // signatures. |
| 61 | 57 | options.entry_name = "__main_void".into(); |
compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs-4| ... | ... | @@ -46,10 +46,6 @@ pub(crate) fn target() -> Target { |
| 46 | 46 | // without a main function. |
| 47 | 47 | options.crt_static_allows_dylibs = true; |
| 48 | 48 | |
| 49 | // WASI's `sys::args::init` function ignores its arguments; instead, | |
| 50 | // `args::args()` makes the WASI API calls itself. | |
| 51 | options.main_needs_argc_argv = false; | |
| 52 | ||
| 53 | 49 | // And, WASI mangles the name of "main" to distinguish between different |
| 54 | 50 | // signatures. |
| 55 | 51 | options.entry_name = "__main_void".into(); |
library/alloc/src/str.rs+4-1| ... | ... | @@ -308,7 +308,10 @@ impl str { |
| 308 | 308 | pub fn replace<P: Pattern>(&self, from: P, to: &str) -> String { |
| 309 | 309 | // Fast path for replacing a single ASCII character with another. |
| 310 | 310 | if let Some(from_byte) = match from.as_utf8_pattern() { |
| 311 | Some(Utf8Pattern::StringPattern([from_byte])) => Some(*from_byte), | |
| 311 | Some(Utf8Pattern::StringPattern(s)) => match s.as_bytes() { | |
| 312 | [from_byte] => Some(*from_byte), | |
| 313 | _ => None, | |
| 314 | }, | |
| 312 | 315 | Some(Utf8Pattern::CharPattern(c)) => c.as_ascii().map(|ascii_char| ascii_char.to_u8()), |
| 313 | 316 | _ => None, |
| 314 | 317 | } { |
library/alloc/src/string.rs+1-1| ... | ... | @@ -2654,7 +2654,7 @@ impl<'b> Pattern for &'b String { |
| 2654 | 2654 | |
| 2655 | 2655 | #[inline] |
| 2656 | 2656 | fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> { |
| 2657 | Some(Utf8Pattern::StringPattern(self.as_bytes())) | |
| 2657 | Some(Utf8Pattern::StringPattern(self.as_str())) | |
| 2658 | 2658 | } |
| 2659 | 2659 | } |
| 2660 | 2660 |
library/core/src/str/pattern.rs+5-3| ... | ... | @@ -161,7 +161,7 @@ pub trait Pattern: Sized { |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | /// Returns the pattern as utf-8 bytes if possible. | |
| 164 | /// Returns the pattern as UTF-8 if possible. | |
| 165 | 165 | fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> { |
| 166 | 166 | None |
| 167 | 167 | } |
| ... | ... | @@ -172,7 +172,9 @@ pub trait Pattern: Sized { |
| 172 | 172 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] |
| 173 | 173 | pub enum Utf8Pattern<'a> { |
| 174 | 174 | /// Type returned by String and str types. |
| 175 | StringPattern(&'a [u8]), | |
| 175 | /// This stores `str` rather than bytes so callers cannot describe | |
| 176 | /// non-UTF-8 string patterns through this API. | |
| 177 | StringPattern(&'a str), | |
| 176 | 178 | /// Type returned by char types. |
| 177 | 179 | CharPattern(char), |
| 178 | 180 | } |
| ... | ... | @@ -1049,7 +1051,7 @@ impl<'b> Pattern for &'b str { |
| 1049 | 1051 | |
| 1050 | 1052 | #[inline] |
| 1051 | 1053 | fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> { |
| 1052 | Some(Utf8Pattern::StringPattern(self.as_bytes())) | |
| 1054 | Some(Utf8Pattern::StringPattern(*self)) | |
| 1053 | 1055 | } |
| 1054 | 1056 | } |
| 1055 | 1057 |
library/std/src/env.rs+1-1| ... | ... | @@ -689,7 +689,7 @@ pub fn home_dir() -> Option<PathBuf> { |
| 689 | 689 | /// [GetTempPath]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha |
| 690 | 690 | /// [appledoc]: https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585-SW10 |
| 691 | 691 | /// |
| 692 | /// ```no_run | |
| 692 | /// ``` | |
| 693 | 693 | /// use std::env; |
| 694 | 694 | /// |
| 695 | 695 | /// fn main() { |
src/librustdoc/html/macro_expansion.rs+15-2| ... | ... | @@ -1,5 +1,8 @@ |
| 1 | use rustc_ast::visit::{Visitor, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt, walk_ty}; | |
| 2 | use rustc_ast::{Crate, Expr, Item, Pat, Stmt, Ty}; | |
| 1 | use rustc_ast::visit::{ | |
| 2 | AssocCtxt, Visitor, walk_assoc_item, walk_crate, walk_expr, walk_item, walk_pat, walk_stmt, | |
| 3 | walk_ty, | |
| 4 | }; | |
| 5 | use rustc_ast::{AssocItem, Crate, Expr, Item, Pat, Stmt, Ty}; | |
| 3 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 4 | 7 | use rustc_span::source_map::SourceMap; |
| 5 | 8 | use rustc_span::{BytePos, Span}; |
| ... | ... | @@ -161,4 +164,14 @@ impl<'ast> Visitor<'ast> for ExpandedCodeVisitor<'ast> { |
| 161 | 164 | walk_ty(self, ty); |
| 162 | 165 | } |
| 163 | 166 | } |
| 167 | ||
| 168 | fn visit_assoc_item(&mut self, item: &'ast AssocItem, ctxt: AssocCtxt) -> Self::Result { | |
| 169 | if item.span.from_expansion() { | |
| 170 | self.handle_new_span(item.span, || { | |
| 171 | rustc_ast_pretty::pprust::assoc_item_to_string(item) | |
| 172 | }); | |
| 173 | } else { | |
| 174 | walk_assoc_item(self, item, ctxt); | |
| 175 | } | |
| 176 | } | |
| 164 | 177 | } |
tests/assembly-llvm/wasm_legacy_eh.rs created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | //@ only-wasm32 | |
| 2 | //@ assembly-output: emit-asm | |
| 3 | //@ compile-flags: -C target-feature=+exception-handling | |
| 4 | //@ compile-flags: -C panic=unwind | |
| 5 | //@ compile-flags: -C llvm-args=-wasm-use-legacy-eh=true | |
| 6 | ||
| 7 | // Verifies that user-supplied `-Cllvm-args` can override an LLVM argument that | |
| 8 | // was set in the target spec. The `wasm32-unknown-unknown` target spec pins | |
| 9 | // `-wasm-use-legacy-eh=false`; this test asserts that passing the opposite | |
| 10 | // value via `-Cllvm-args` switches code generation back to the legacy | |
| 11 | // exception-handling instructions. | |
| 12 | ||
| 13 | #![crate_type = "lib"] | |
| 14 | #![feature(core_intrinsics)] | |
| 15 | ||
| 16 | extern "C-unwind" { | |
| 17 | fn may_panic(); | |
| 18 | } | |
| 19 | ||
| 20 | extern "C" { | |
| 21 | fn log_number(number: usize); | |
| 22 | } | |
| 23 | ||
| 24 | struct LogOnDrop; | |
| 25 | ||
| 26 | impl Drop for LogOnDrop { | |
| 27 | fn drop(&mut self) { | |
| 28 | unsafe { | |
| 29 | log_number(0); | |
| 30 | } | |
| 31 | } | |
| 32 | } | |
| 33 | ||
| 34 | // CHECK-LABEL: test_cleanup: | |
| 35 | #[no_mangle] | |
| 36 | pub fn test_cleanup() { | |
| 37 | let _log_on_drop = LogOnDrop; | |
| 38 | unsafe { | |
| 39 | may_panic(); | |
| 40 | } | |
| 41 | ||
| 42 | // CHECK-NOT: try_table | |
| 43 | // CHECK-NOT: catch_all_ref | |
| 44 | // CHECK-NOT: throw_ref | |
| 45 | // CHECK-NOT: call | |
| 46 | // CHECK: try | |
| 47 | // CHECK: call may_panic | |
| 48 | // CHECK: catch_all | |
| 49 | // CHECK: rethrow | |
| 50 | // CHECK: end_try | |
| 51 | } | |
| 52 | ||
| 53 | // CHECK-LABEL: test_rtry: | |
| 54 | #[no_mangle] | |
| 55 | pub fn test_rtry() { | |
| 56 | unsafe { | |
| 57 | core::intrinsics::catch_unwind( | |
| 58 | |_| { | |
| 59 | may_panic(); | |
| 60 | }, | |
| 61 | core::ptr::null_mut(), | |
| 62 | |data, exception| { | |
| 63 | log_number(data as usize); | |
| 64 | log_number(exception as usize); | |
| 65 | }, | |
| 66 | ); | |
| 67 | } | |
| 68 | ||
| 69 | // CHECK-NOT: try_table | |
| 70 | // CHECK-NOT: catch_all_ref | |
| 71 | // CHECK-NOT: throw_ref | |
| 72 | // CHECK-NOT: call | |
| 73 | // CHECK: try | |
| 74 | // CHECK: call may_panic | |
| 75 | // CHECK: catch | |
| 76 | // CHECK: call log_number | |
| 77 | // CHECK: call log_number | |
| 78 | // CHECK-NOT: rethrow | |
| 79 | // CHECK: end_try | |
| 80 | } |
tests/coverage/macros/context-mismatch-issue-147339.cov-map+6-26| ... | ... | @@ -1,40 +1,20 @@ |
| 1 | Function name: context_mismatch_issue_147339::a (unused) | |
| 2 | Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c] | |
| 1 | Function name: context_mismatch_issue_147339::_function (unused) | |
| 2 | Raw bytes (14): 0x[01, 01, 00, 02, 00, 14, 11, 00, 26, 00, 02, 11, 00, 12] | |
| 3 | 3 | Number of files: 1 |
| 4 | 4 | - file 0 => $DIR/context-mismatch-issue-147339.rs |
| 5 | 5 | Number of expressions: 0 |
| 6 | 6 | Number of file 0 mappings: 2 |
| 7 | - Code(Zero) at (prev + 12, 39) to (start + 0, 53) | |
| 8 | - Code(Zero) at (prev + 0, 59) to (start + 0, 60) | |
| 9 | Highest counter ID seen: (none) | |
| 10 | ||
| 11 | Function name: context_mismatch_issue_147339::b (unused) | |
| 12 | Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c] | |
| 13 | Number of files: 1 | |
| 14 | - file 0 => $DIR/context-mismatch-issue-147339.rs | |
| 15 | Number of expressions: 0 | |
| 16 | Number of file 0 mappings: 2 | |
| 17 | - Code(Zero) at (prev + 12, 39) to (start + 0, 53) | |
| 18 | - Code(Zero) at (prev + 0, 59) to (start + 0, 60) | |
| 19 | Highest counter ID seen: (none) | |
| 20 | ||
| 21 | Function name: context_mismatch_issue_147339::c (unused) | |
| 22 | Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c] | |
| 23 | Number of files: 1 | |
| 24 | - file 0 => $DIR/context-mismatch-issue-147339.rs | |
| 25 | Number of expressions: 0 | |
| 26 | Number of file 0 mappings: 2 | |
| 27 | - Code(Zero) at (prev + 12, 39) to (start + 0, 53) | |
| 28 | - Code(Zero) at (prev + 0, 59) to (start + 0, 60) | |
| 7 | - Code(Zero) at (prev + 20, 17) to (start + 0, 38) | |
| 8 | - Code(Zero) at (prev + 2, 17) to (start + 0, 18) | |
| 29 | 9 | Highest counter ID seen: (none) |
| 30 | 10 | |
| 31 | 11 | Function name: context_mismatch_issue_147339::main |
| 32 | Raw bytes (14): 0x[01, 01, 00, 02, 01, 14, 01, 00, 0a, 01, 00, 0c, 00, 0d] | |
| 12 | Raw bytes (14): 0x[01, 01, 00, 02, 01, 1f, 01, 00, 0a, 01, 00, 0c, 00, 0d] | |
| 33 | 13 | Number of files: 1 |
| 34 | 14 | - file 0 => $DIR/context-mismatch-issue-147339.rs |
| 35 | 15 | Number of expressions: 0 |
| 36 | 16 | Number of file 0 mappings: 2 |
| 37 | - Code(Counter(0)) at (prev + 20, 1) to (start + 0, 10) | |
| 17 | - Code(Counter(0)) at (prev + 31, 1) to (start + 0, 10) | |
| 38 | 18 | - Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13) |
| 39 | 19 | Highest counter ID seen: c0 |
| 40 | 20 |
tests/coverage/macros/context-mismatch-issue-147339.coverage+19-15| ... | ... | @@ -6,23 +6,27 @@ |
| 6 | 6 | LL| |// |
| 7 | 7 | LL| |// Reported in <https://github.com/rust-lang/rust/issues/147339>. |
| 8 | 8 | LL| | |
| 9 | LL| |macro_rules! foo { | |
| 10 | LL| | ($($m:ident $($f:ident $v:tt)+),*) => { | |
| 11 | LL| | $($(macro_rules! $f { () => { $v } })+)* | |
| 12 | LL| 0| $(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })* | |
| 13 | ------------------ | |
| 14 | | Unexecuted instantiation: context_mismatch_issue_147339::a | |
| 15 | ------------------ | |
| 16 | | Unexecuted instantiation: context_mismatch_issue_147339::b | |
| 17 | ------------------ | |
| 18 | | Unexecuted instantiation: context_mismatch_issue_147339::c | |
| 19 | ------------------ | |
| 20 | LL| | } | |
| 9 | LL| |macro_rules! outer_macro { | |
| 10 | LL| | ( | |
| 11 | LL| | $v:tt | |
| 12 | LL| | ) => { | |
| 13 | LL| | macro_rules! _other_macro_that_mentions_v { | |
| 14 | LL| | () => { | |
| 15 | LL| | $v | |
| 16 | LL| | }; | |
| 17 | LL| | } | |
| 18 | LL| | macro_rules! inner_macro { | |
| 19 | LL| | () => { | |
| 20 | LL| 0| fn _function() -> i32 { | |
| 21 | LL| | $v | |
| 22 | LL| 0| } | |
| 23 | LL| | }; | |
| 24 | LL| | } | |
| 25 | LL| | }; | |
| 21 | 26 | LL| |} |
| 22 | 27 | LL| | |
| 23 | LL| |foo!(m a 1 b 2, n c 3); | |
| 24 | LL| |m!(); | |
| 25 | LL| |n!(); | |
| 28 | LL| |outer_macro!(1); | |
| 29 | LL| |inner_macro!(); | |
| 26 | 30 | LL| | |
| 27 | 31 | LL| 1|fn main() {} |
| 28 | 32 |
tests/coverage/macros/context-mismatch-issue-147339.rs+19-8| ... | ... | @@ -6,15 +6,26 @@ |
| 6 | 6 | // |
| 7 | 7 | // Reported in <https://github.com/rust-lang/rust/issues/147339>. |
| 8 | 8 | |
| 9 | macro_rules! foo { | |
| 10 | ($($m:ident $($f:ident $v:tt)+),*) => { | |
| 11 | $($(macro_rules! $f { () => { $v } })+)* | |
| 12 | $(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })* | |
| 13 | } | |
| 9 | macro_rules! outer_macro { | |
| 10 | ( | |
| 11 | $v:tt | |
| 12 | ) => { | |
| 13 | macro_rules! _other_macro_that_mentions_v { | |
| 14 | () => { | |
| 15 | $v | |
| 16 | }; | |
| 17 | } | |
| 18 | macro_rules! inner_macro { | |
| 19 | () => { | |
| 20 | fn _function() -> i32 { | |
| 21 | $v | |
| 22 | } | |
| 23 | }; | |
| 24 | } | |
| 25 | }; | |
| 14 | 26 | } |
| 15 | 27 | |
| 16 | foo!(m a 1 b 2, n c 3); | |
| 17 | m!(); | |
| 18 | n!(); | |
| 28 | outer_macro!(1); | |
| 29 | inner_macro!(); | |
| 19 | 30 | |
| 20 | 31 | fn main() {} |
tests/rustdoc-html/macro-expansion/assoc-items-decl-macro.rs created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | // Ensure assoc items work for decl macros. | |
| 2 | // Regression test for <https://github.com/rust-lang/rust/issues/156075>. | |
| 3 | ||
| 4 | //@ compile-flags: -Zunstable-options --generate-macro-expansion | |
| 5 | ||
| 6 | #![crate_name = "foo"] | |
| 7 | #![feature(decl_macro)] | |
| 8 | ||
| 9 | //@ has 'src/foo/assoc-items-decl-macro.rs.html' | |
| 10 | ||
| 11 | pub macro first() { | |
| 12 | type P1 = bool; | |
| 13 | fn u1() {} | |
| 14 | } | |
| 15 | ||
| 16 | trait C1 { | |
| 17 | type P1; | |
| 18 | fn u1(); | |
| 19 | } | |
| 20 | ||
| 21 | impl C1 for u32 { | |
| 22 | //@ matches - '//*[@class="expansion"]/*[@class="expanded"]' 'type P1 = bool;\nfn u1\(\) {}' | |
| 23 | first!(); | |
| 24 | } |
tests/rustdoc-html/macro-expansion/assoc-items-macro.rs created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | // Ensure assoc items work for macro rules. | |
| 2 | // Regression test for <https://github.com/rust-lang/rust/issues/156075>. | |
| 3 | ||
| 4 | //@ compile-flags: -Zunstable-options --generate-macro-expansion | |
| 5 | ||
| 6 | #![crate_name = "foo"] | |
| 7 | ||
| 8 | //@ has 'src/foo/assoc-items-macro.rs.html' | |
| 9 | ||
| 10 | macro_rules! first { | |
| 11 | () => { | |
| 12 | type P1 = bool; | |
| 13 | fn u1() {} | |
| 14 | } | |
| 15 | } | |
| 16 | ||
| 17 | trait C1 { | |
| 18 | type P1; | |
| 19 | fn u1(); | |
| 20 | } | |
| 21 | ||
| 22 | impl C1 for u32 { | |
| 23 | //@ matches - '//*[@class="expansion"]/*[@class="expanded"]' 'type P1 = bool;\nfn u1\(\) {}' | |
| 24 | first!(); | |
| 25 | } |
tests/rustdoc-ui/not-wf-ambiguous-normalization.stderr+4-1| ... | ... | @@ -2,7 +2,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/not-wf-ambiguous-normalization.rs:14:6 |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T> Allocator for DefaultAllocator { |
| 5 | | ^ unconstrained type parameter | |
| 5 | | -^- | |
| 6 | | || | |
| 7 | | |unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `T` | |
| 6 | 9 | |
| 7 | 10 | error: aborting due to 1 previous error |
| 8 | 11 |
tests/rustdoc-ui/synthetic-auto-trait-impls/unconstrained-param-in-impl-ambiguity.stderr+4-1| ... | ... | @@ -2,7 +2,10 @@ error[E0207]: the type parameter `Q` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/unconstrained-param-in-impl-ambiguity.rs:7:13 |
| 3 | 3 | | |
| 4 | 4 | LL | unsafe impl<Q: Trait> Send for Inner {} |
| 5 | | ^ unconstrained type parameter | |
| 5 | | -^-------- | |
| 6 | | || | |
| 7 | | |unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `Q` | |
| 6 | 9 | |
| 7 | 10 | error: aborting due to 1 previous error |
| 8 | 11 |
tests/ui/associated-inherent-types/hr-do-not-blame-outlives-static-ice.stderr+7| ... | ... | @@ -3,6 +3,13 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, |
| 3 | 3 | | |
| 4 | 4 | LL | impl<'a> Foo<fn(&())> { |
| 5 | 5 | | ^^ unconstrained lifetime parameter |
| 6 | | | |
| 7 | help: use the lifetime parameter `'a` in the `Foo` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Foo<T, 'a>(T); | |
| 10 | LL | | |
| 11 | LL ~ impl<'a> Foo<fn(&()), 'a> { | |
| 12 | | | |
| 6 | 13 | |
| 7 | 14 | error[E0308]: mismatched types |
| 8 | 15 | --> $DIR/hr-do-not-blame-outlives-static-ice.rs:13:11 |
tests/ui/associated-inherent-types/inherent-assoc-ty-mismatch-issue-153539.stderr+4-1| ... | ... | @@ -2,7 +2,10 @@ error[E0207]: the type parameter `X` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/inherent-assoc-ty-mismatch-issue-153539.rs:9:6 |
| 3 | 3 | | |
| 4 | 4 | LL | impl<X> S<'_> { |
| 5 | | ^ unconstrained type parameter | |
| 5 | | -^- | |
| 6 | | || | |
| 7 | | |unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `X` | |
| 6 | 9 | |
| 7 | 10 | error[E0308]: mismatched types |
| 8 | 11 | --> $DIR/inherent-assoc-ty-mismatch-issue-153539.rs:17:5 |
tests/ui/associated-inherent-types/next-solver-opaque-inherent-fn-ptr-issue-155204.stderr+4-1| ... | ... | @@ -27,7 +27,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 27 | 27 | --> $DIR/next-solver-opaque-inherent-fn-ptr-issue-155204.rs:7:6 |
| 28 | 28 | | |
| 29 | 29 | LL | impl<T> Windows<fn(&())> { |
| 30 | | ^ unconstrained type parameter | |
| 30 | | -^- | |
| 31 | | || | |
| 32 | | |unconstrained type parameter | |
| 33 | | help: remove the unused type parameter `T` | |
| 31 | 34 | |
| 32 | 35 | error[E0282]: type annotations needed |
| 33 | 36 | --> $DIR/next-solver-opaque-inherent-fn-ptr-issue-155204.rs:12:22 |
tests/ui/associated-inherent-types/next-solver-opaque-inherent-no-ice.stderr+4-1| ... | ... | @@ -24,7 +24,10 @@ error[E0207]: the const parameter `X` is not constrained by the impl trait, self |
| 24 | 24 | --> $DIR/next-solver-opaque-inherent-no-ice.rs:6:6 |
| 25 | 25 | | |
| 26 | 26 | LL | impl<const X: y> Foo { |
| 27 | | ^^^^^^^^^^ unconstrained const parameter | |
| 27 | | -^^^^^^^^^^- | |
| 28 | | || | |
| 29 | | |unconstrained const parameter | |
| 30 | | help: remove the unused type parameter `X` | |
| 28 | 31 | | |
| 29 | 32 | = note: expressions using a const parameter must map each value to a distinct output value |
| 30 | 33 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/associated-types/issue-26262.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T: Tr> S<T::Assoc> { |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `S` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct S<T, T>(T); | |
| 10 | LL | | |
| 11 | LL | trait Tr { type Assoc; fn test(); } | |
| 12 | LL | | |
| 13 | LL ~ impl<T: Tr> S<T::Assoc, T> { | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates |
| 8 | 17 | --> $DIR/issue-26262.rs:17:6 |
tests/ui/associated-types/unconstrained-lifetime-assoc-type.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, |
| 3 | 3 | | |
| 4 | 4 | LL | impl<'a> Fun for Holder { |
| 5 | 5 | | ^^ unconstrained lifetime parameter |
| 6 | | | |
| 7 | help: use the lifetime parameter `'a` in the `Holder` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Holder<'a> { | |
| 10 | LL | x: String, | |
| 11 | LL | } | |
| 12 | LL | | |
| 13 | LL ~ impl<'a> Fun for Holder<'a> { | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error: aborting due to 1 previous error |
| 8 | 17 |
tests/ui/async-await/issues/issue-78654.full.stderr+4-1| ... | ... | @@ -8,7 +8,10 @@ error[E0207]: the const parameter `H` is not constrained by the impl trait, self |
| 8 | 8 | --> $DIR/issue-78654.rs:9:6 |
| 9 | 9 | | |
| 10 | 10 | LL | impl<const H: feature> Foo { |
| 11 | | ^^^^^^^^^^^^^^^^ unconstrained const parameter | |
| 11 | | -^^^^^^^^^^^^^^^^- | |
| 12 | | || | |
| 13 | | |unconstrained const parameter | |
| 14 | | help: remove the unused type parameter `H` | |
| 12 | 15 | | |
| 13 | 16 | = note: expressions using a const parameter must map each value to a distinct output value |
| 14 | 17 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/async-await/issues/issue-78654.min.stderr+4-1| ... | ... | @@ -8,7 +8,10 @@ error[E0207]: the const parameter `H` is not constrained by the impl trait, self |
| 8 | 8 | --> $DIR/issue-78654.rs:9:6 |
| 9 | 9 | | |
| 10 | 10 | LL | impl<const H: feature> Foo { |
| 11 | | ^^^^^^^^^^^^^^^^ unconstrained const parameter | |
| 11 | | -^^^^^^^^^^^^^^^^- | |
| 12 | | || | |
| 13 | | |unconstrained const parameter | |
| 14 | | help: remove the unused type parameter `H` | |
| 12 | 15 | | |
| 13 | 16 | = note: expressions using a const parameter must map each value to a distinct output value |
| 14 | 17 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/const-generics/adt_const_params/unsized-anon-const-err-2.stderr+8-2| ... | ... | @@ -37,7 +37,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self |
| 37 | 37 | --> $DIR/unsized-anon-const-err-2.rs:13:6 |
| 38 | 38 | | |
| 39 | 39 | LL | impl<const N: i32> Copy for S<A> {} |
| 40 | | ^^^^^^^^^^^^ unconstrained const parameter | |
| 40 | | -^^^^^^^^^^^^- | |
| 41 | | || | |
| 42 | | |unconstrained const parameter | |
| 43 | | help: remove the unused type parameter `N` | |
| 41 | 44 | | |
| 42 | 45 | = note: expressions using a const parameter must map each value to a distinct output value |
| 43 | 46 | = note: proving the result of expressions other than the parameter are unique is not supported |
| ... | ... | @@ -46,7 +49,10 @@ error[E0207]: the const parameter `M` is not constrained by the impl trait, self |
| 46 | 49 | --> $DIR/unsized-anon-const-err-2.rs:16:6 |
| 47 | 50 | | |
| 48 | 51 | LL | impl<const M: usize> Copy for S<A> {} |
| 49 | | ^^^^^^^^^^^^^^ unconstrained const parameter | |
| 52 | | -^^^^^^^^^^^^^^- | |
| 53 | | || | |
| 54 | | |unconstrained const parameter | |
| 55 | | help: remove the unused type parameter `M` | |
| 50 | 56 | | |
| 51 | 57 | = note: expressions using a const parameter must map each value to a distinct output value |
| 52 | 58 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr+4-1| ... | ... | @@ -24,7 +24,10 @@ error[E0207]: the const parameter `NUM` is not constrained by the impl trait, se |
| 24 | 24 | --> $DIR/post-analysis-user-facing-param-env.rs:5:10 |
| 25 | 25 | | |
| 26 | 26 | LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo |
| 27 | | ^^^^^^^^^^^^^^^^ unconstrained const parameter | |
| 27 | | --^^^^^^^^^^^^^^^^ | |
| 28 | | | | | |
| 29 | | | unconstrained const parameter | |
| 30 | | help: remove the unused type parameter `NUM` | |
| 28 | 31 | | |
| 29 | 32 | = note: expressions using a const parameter must map each value to a distinct output value |
| 30 | 33 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr+8| ... | ... | @@ -71,6 +71,14 @@ LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { |
| 71 | 71 | | |
| 72 | 72 | = note: expressions using a const parameter must map each value to a distinct output value |
| 73 | 73 | = note: proving the result of expressions other than the parameter are unique is not supported |
| 74 | help: use the type parameter `N` in the `ConstChunksExact` type and use it in the type definition | |
| 75 | | | |
| 76 | LL ~ struct ConstChunksExact<'rem, T: 'a, const N: usize, N> {} | |
| 77 | LL | | |
| 78 | LL | | |
| 79 | LL | | |
| 80 | LL ~ impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}, N> { | |
| 81 | | | |
| 74 | 82 | |
| 75 | 83 | error: aborting due to 8 previous errors |
| 76 | 84 |
tests/ui/const-generics/issues/issue-68366.full.stderr+8-2| ... | ... | @@ -14,7 +14,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self |
| 14 | 14 | --> $DIR/issue-68366.rs:12:7 |
| 15 | 15 | | |
| 16 | 16 | LL | impl <const N: usize> Collatz<{Some(N)}> {} |
| 17 | | ^^^^^^^^^^^^^^ unconstrained const parameter | |
| 17 | | -^^^^^^^^^^^^^^- | |
| 18 | | || | |
| 19 | | |unconstrained const parameter | |
| 20 | | help: remove the unused type parameter `N` | |
| 18 | 21 | | |
| 19 | 22 | = note: expressions using a const parameter must map each value to a distinct output value |
| 20 | 23 | = note: proving the result of expressions other than the parameter are unique is not supported |
| ... | ... | @@ -23,7 +26,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self |
| 23 | 26 | --> $DIR/issue-68366.rs:19:6 |
| 24 | 27 | | |
| 25 | 28 | LL | impl<const N: usize> Foo {} |
| 26 | | ^^^^^^^^^^^^^^ unconstrained const parameter | |
| 29 | | -^^^^^^^^^^^^^^- | |
| 30 | | || | |
| 31 | | |unconstrained const parameter | |
| 32 | | help: remove the unused type parameter `N` | |
| 27 | 33 | | |
| 28 | 34 | = note: expressions using a const parameter must map each value to a distinct output value |
| 29 | 35 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/const-generics/issues/issue-68366.min.stderr+8-2| ... | ... | @@ -23,7 +23,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self |
| 23 | 23 | --> $DIR/issue-68366.rs:12:7 |
| 24 | 24 | | |
| 25 | 25 | LL | impl <const N: usize> Collatz<{Some(N)}> {} |
| 26 | | ^^^^^^^^^^^^^^ unconstrained const parameter | |
| 26 | | -^^^^^^^^^^^^^^- | |
| 27 | | || | |
| 28 | | |unconstrained const parameter | |
| 29 | | help: remove the unused type parameter `N` | |
| 27 | 30 | | |
| 28 | 31 | = note: expressions using a const parameter must map each value to a distinct output value |
| 29 | 32 | = note: proving the result of expressions other than the parameter are unique is not supported |
| ... | ... | @@ -32,7 +35,10 @@ error[E0207]: the const parameter `N` is not constrained by the impl trait, self |
| 32 | 35 | --> $DIR/issue-68366.rs:19:6 |
| 33 | 36 | | |
| 34 | 37 | LL | impl<const N: usize> Foo {} |
| 35 | | ^^^^^^^^^^^^^^ unconstrained const parameter | |
| 38 | | -^^^^^^^^^^^^^^- | |
| 39 | | || | |
| 40 | | |unconstrained const parameter | |
| 41 | | help: remove the unused type parameter `N` | |
| 36 | 42 | | |
| 37 | 43 | = note: expressions using a const parameter must map each value to a distinct output value |
| 38 | 44 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr+8| ... | ... | @@ -53,6 +53,14 @@ LL | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact< |
| 53 | 53 | | |
| 54 | 54 | = note: expressions using a const parameter must map each value to a distinct output value |
| 55 | 55 | = note: proving the result of expressions other than the parameter are unique is not supported |
| 56 | help: use the type parameter `N` in the `ConstChunksExact` type and use it in the type definition | |
| 57 | | | |
| 58 | LL ~ struct ConstChunksExact<'a, T: '_, const assert: usize, N> {} | |
| 59 | LL | | |
| 60 | LL | | |
| 61 | LL | | |
| 62 | LL ~ impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}, N> { | |
| 63 | | | |
| 56 | 64 | |
| 57 | 65 | error[E0308]: mismatched types |
| 58 | 66 | --> $DIR/normalizing_with_unconstrained_impl_params.rs:6:27 |
tests/ui/delegation/generics/free-to-trait-static-reuse.rs+6| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | //@ compile-flags: -Z deduplicate-diagnostics=yes | |
| 2 | ||
| 1 | 3 | #![feature(fn_delegation)] |
| 2 | 4 | |
| 3 | 5 | trait Bound<T> {} |
| ... | ... | @@ -19,12 +21,16 @@ reuse <usize as Trait>::static_method::<'static, Vec<i32>, false> as bar2; |
| 19 | 21 | |
| 20 | 22 | reuse Trait::static_method as error { self - 123 } |
| 21 | 23 | //~^ ERROR: type annotations needed |
| 24 | //~| ERROR: delegation self type is not specified | |
| 22 | 25 | reuse Trait::<'static, i32, 123>::static_method as error2; |
| 23 | 26 | //~^ ERROR: type annotations needed |
| 27 | //~| ERROR: delegation self type is not specified | |
| 24 | 28 | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3; |
| 25 | 29 | //~^ ERROR: type annotations needed |
| 30 | //~| ERROR: delegation self type is not specified | |
| 26 | 31 | reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 } |
| 27 | 32 | //~^ ERROR: type annotations needed |
| 33 | //~| ERROR: delegation self type is not specified | |
| 28 | 34 | |
| 29 | 35 | reuse <String as Trait>::static_method as error5; |
| 30 | 36 | //~^ ERROR: the trait bound `String: Trait<'a, T, X>` is not satisfied |
tests/ui/delegation/generics/free-to-trait-static-reuse.stderr+51-19| ... | ... | @@ -1,21 +1,53 @@ |
| 1 | error: delegation self type is not specified | |
| 2 | --> $DIR/free-to-trait-static-reuse.rs:22:14 | |
| 3 | | | |
| 4 | LL | reuse Trait::static_method as error { self - 123 } | |
| 5 | | ^^^^^^^^^^^^^ | |
| 6 | | | |
| 7 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 8 | ||
| 9 | error: delegation self type is not specified | |
| 10 | --> $DIR/free-to-trait-static-reuse.rs:25:35 | |
| 11 | | | |
| 12 | LL | reuse Trait::<'static, i32, 123>::static_method as error2; | |
| 13 | | ^^^^^^^^^^^^^ | |
| 14 | | | |
| 15 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 16 | ||
| 17 | error: delegation self type is not specified | |
| 18 | --> $DIR/free-to-trait-static-reuse.rs:28:35 | |
| 19 | | | |
| 20 | LL | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3; | |
| 21 | | ^^^^^^^^^^^^^ | |
| 22 | | | |
| 23 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 24 | ||
| 25 | error: delegation self type is not specified | |
| 26 | --> $DIR/free-to-trait-static-reuse.rs:31:14 | |
| 27 | | | |
| 28 | LL | reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 } | |
| 29 | | ^^^^^^^^^^^^^ | |
| 30 | | | |
| 31 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 32 | ||
| 1 | 33 | error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied |
| 2 | --> $DIR/free-to-trait-static-reuse.rs:33:49 | |
| 34 | --> $DIR/free-to-trait-static-reuse.rs:39:49 | |
| 3 | 35 | | |
| 4 | 36 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} |
| 5 | 37 | | ^^^^^^ unsatisfied trait bound |
| 6 | 38 | | |
| 7 | 39 | help: the trait `Bound<T>` is not implemented for `Struct` |
| 8 | --> $DIR/free-to-trait-static-reuse.rs:32:1 | |
| 40 | --> $DIR/free-to-trait-static-reuse.rs:38:1 | |
| 9 | 41 | | |
| 10 | 42 | LL | struct Struct; |
| 11 | 43 | | ^^^^^^^^^^^^^ |
| 12 | 44 | help: the trait `Bound<T>` is implemented for `usize` |
| 13 | --> $DIR/free-to-trait-static-reuse.rs:13:1 | |
| 45 | --> $DIR/free-to-trait-static-reuse.rs:15:1 | |
| 14 | 46 | | |
| 15 | 47 | LL | impl<T> Bound<T> for usize {} |
| 16 | 48 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 17 | 49 | note: required by a bound in `Trait` |
| 18 | --> $DIR/free-to-trait-static-reuse.rs:7:11 | |
| 50 | --> $DIR/free-to-trait-static-reuse.rs:9:11 | |
| 19 | 51 | | |
| 20 | 52 | LL | trait Trait<'a, T, const X: usize> |
| 21 | 53 | | ----- required by a bound in this trait |
| ... | ... | @@ -24,13 +56,13 @@ LL | Self: Bound<T>, |
| 24 | 56 | | ^^^^^^^^ required by this bound in `Trait` |
| 25 | 57 | |
| 26 | 58 | error[E0283]: type annotations needed |
| 27 | --> $DIR/free-to-trait-static-reuse.rs:20:14 | |
| 59 | --> $DIR/free-to-trait-static-reuse.rs:22:14 | |
| 28 | 60 | | |
| 29 | 61 | LL | reuse Trait::static_method as error { self - 123 } |
| 30 | 62 | | ^^^^^^^^^^^^^ cannot infer type |
| 31 | 63 | | |
| 32 | 64 | note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found |
| 33 | --> $DIR/free-to-trait-static-reuse.rs:12:1 | |
| 65 | --> $DIR/free-to-trait-static-reuse.rs:14:1 | |
| 34 | 66 | | |
| 35 | 67 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} |
| 36 | 68 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| ... | ... | @@ -39,13 +71,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} |
| 39 | 71 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 40 | 72 | |
| 41 | 73 | error[E0283]: type annotations needed |
| 42 | --> $DIR/free-to-trait-static-reuse.rs:22:35 | |
| 74 | --> $DIR/free-to-trait-static-reuse.rs:25:35 | |
| 43 | 75 | | |
| 44 | 76 | LL | reuse Trait::<'static, i32, 123>::static_method as error2; |
| 45 | 77 | | ^^^^^^^^^^^^^ cannot infer type |
| 46 | 78 | | |
| 47 | 79 | note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found |
| 48 | --> $DIR/free-to-trait-static-reuse.rs:12:1 | |
| 80 | --> $DIR/free-to-trait-static-reuse.rs:14:1 | |
| 49 | 81 | | |
| 50 | 82 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} |
| 51 | 83 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| ... | ... | @@ -54,13 +86,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} |
| 54 | 86 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 55 | 87 | |
| 56 | 88 | error[E0283]: type annotations needed |
| 57 | --> $DIR/free-to-trait-static-reuse.rs:24:35 | |
| 89 | --> $DIR/free-to-trait-static-reuse.rs:28:35 | |
| 58 | 90 | | |
| 59 | 91 | LL | reuse Trait::<'static, i32, 123>::static_method::<'static, String, false> as error3; |
| 60 | 92 | | ^^^^^^^^^^^^^ cannot infer type |
| 61 | 93 | | |
| 62 | 94 | note: multiple `impl`s satisfying `_: Trait<'static, i32, 123>` found |
| 63 | --> $DIR/free-to-trait-static-reuse.rs:12:1 | |
| 95 | --> $DIR/free-to-trait-static-reuse.rs:14:1 | |
| 64 | 96 | | |
| 65 | 97 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} |
| 66 | 98 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| ... | ... | @@ -69,13 +101,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} |
| 69 | 101 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 70 | 102 | |
| 71 | 103 | error[E0283]: type annotations needed |
| 72 | --> $DIR/free-to-trait-static-reuse.rs:26:14 | |
| 104 | --> $DIR/free-to-trait-static-reuse.rs:31:14 | |
| 73 | 105 | | |
| 74 | 106 | LL | reuse Trait::static_method::<'static, Vec<i32>, false> as error4 { self + 4 } |
| 75 | 107 | | ^^^^^^^^^^^^^ cannot infer type |
| 76 | 108 | | |
| 77 | 109 | note: multiple `impl`s satisfying `_: Trait<'a, T, X>` found |
| 78 | --> $DIR/free-to-trait-static-reuse.rs:12:1 | |
| 110 | --> $DIR/free-to-trait-static-reuse.rs:14:1 | |
| 79 | 111 | | |
| 80 | 112 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} |
| 81 | 113 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| ... | ... | @@ -84,13 +116,13 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} |
| 84 | 116 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 85 | 117 | |
| 86 | 118 | error[E0277]: the trait bound `String: Trait<'a, T, X>` is not satisfied |
| 87 | --> $DIR/free-to-trait-static-reuse.rs:29:8 | |
| 119 | --> $DIR/free-to-trait-static-reuse.rs:35:8 | |
| 88 | 120 | | |
| 89 | 121 | LL | reuse <String as Trait>::static_method as error5; |
| 90 | 122 | | ^^^^^^ the trait `Trait<'a, T, X>` is not implemented for `String` |
| 91 | 123 | | |
| 92 | 124 | help: the following other types implement trait `Trait<'a, T, X>` |
| 93 | --> $DIR/free-to-trait-static-reuse.rs:12:1 | |
| 125 | --> $DIR/free-to-trait-static-reuse.rs:14:1 | |
| 94 | 126 | | |
| 95 | 127 | LL | impl<'a, T, const X: usize> Trait<'a, T, X> for usize {} |
| 96 | 128 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `usize` |
| ... | ... | @@ -99,23 +131,23 @@ LL | impl<'a, T, const X: usize> Trait<'a, T, X> for Struct {} |
| 99 | 131 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Struct` |
| 100 | 132 | |
| 101 | 133 | error[E0277]: the trait bound `Struct: Bound<T>` is not satisfied |
| 102 | --> $DIR/free-to-trait-static-reuse.rs:36:8 | |
| 134 | --> $DIR/free-to-trait-static-reuse.rs:42:8 | |
| 103 | 135 | | |
| 104 | 136 | LL | reuse <Struct as Trait>::static_method as error6; |
| 105 | 137 | | ^^^^^^ unsatisfied trait bound |
| 106 | 138 | | |
| 107 | 139 | help: the trait `Bound<T>` is not implemented for `Struct` |
| 108 | --> $DIR/free-to-trait-static-reuse.rs:32:1 | |
| 140 | --> $DIR/free-to-trait-static-reuse.rs:38:1 | |
| 109 | 141 | | |
| 110 | 142 | LL | struct Struct; |
| 111 | 143 | | ^^^^^^^^^^^^^ |
| 112 | 144 | help: the trait `Bound<T>` is implemented for `usize` |
| 113 | --> $DIR/free-to-trait-static-reuse.rs:13:1 | |
| 145 | --> $DIR/free-to-trait-static-reuse.rs:15:1 | |
| 114 | 146 | | |
| 115 | 147 | LL | impl<T> Bound<T> for usize {} |
| 116 | 148 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 117 | 149 | note: required by a bound in `Trait::static_method` |
| 118 | --> $DIR/free-to-trait-static-reuse.rs:7:11 | |
| 150 | --> $DIR/free-to-trait-static-reuse.rs:9:11 | |
| 119 | 151 | | |
| 120 | 152 | LL | Self: Bound<T>, |
| 121 | 153 | | ^^^^^^^^ required by this bound in `Trait::static_method` |
| ... | ... | @@ -123,7 +155,7 @@ LL | { |
| 123 | 155 | LL | fn static_method<'c: 'c, U, const B: bool>(x: usize) {} |
| 124 | 156 | | ------------- required by a bound in this associated function |
| 125 | 157 | |
| 126 | error: aborting due to 7 previous errors | |
| 158 | error: aborting due to 11 previous errors | |
| 127 | 159 | |
| 128 | 160 | Some errors have detailed explanations: E0277, E0283. |
| 129 | 161 | For more information about an error, try `rustc --explain E0277`. |
tests/ui/delegation/self-ty-ice-156388.rs created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | //@ compile-flags: -Z deduplicate-diagnostics=yes | |
| 2 | ||
| 3 | #![feature(fn_delegation)] | |
| 4 | ||
| 5 | reuse Default::default; | |
| 6 | //~^ ERROR: delegation self type is not specified | |
| 7 | ||
| 8 | fn main() {} |
tests/ui/delegation/self-ty-ice-156388.stderr created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | error: delegation self type is not specified | |
| 2 | --> $DIR/self-ty-ice-156388.rs:5:16 | |
| 3 | | | |
| 4 | LL | reuse Default::default; | |
| 5 | | ^^^^^^^ | |
| 6 | | | |
| 7 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 8 | ||
| 9 | error: aborting due to 1 previous error | |
| 10 |
tests/ui/delegation/target-expr.rs+3| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | //@ compile-flags: -Z deduplicate-diagnostics=yes | |
| 2 | ||
| 1 | 3 | #![feature(fn_delegation)] |
| 2 | 4 | |
| 3 | 5 | trait Trait { |
| ... | ... | @@ -14,6 +16,7 @@ fn foo(x: i32) -> i32 { x } |
| 14 | 16 | fn bar<T: Default>(_: T) { |
| 15 | 17 | reuse Trait::static_method { |
| 16 | 18 | //~^ ERROR mismatched types |
| 19 | //~| ERROR: delegation self type is not specified | |
| 17 | 20 | let _ = T::Default(); |
| 18 | 21 | //~^ ERROR can't use generic parameters from outer item |
| 19 | 22 | } |
tests/ui/delegation/target-expr.stderr+17-8| ... | ... | @@ -1,18 +1,18 @@ |
| 1 | 1 | error[E0401]: can't use generic parameters from outer item |
| 2 | --> $DIR/target-expr.rs:17:17 | |
| 2 | --> $DIR/target-expr.rs:20:17 | |
| 3 | 3 | | |
| 4 | 4 | LL | fn bar<T: Default>(_: T) { |
| 5 | 5 | | - type parameter from outer item |
| 6 | 6 | LL | reuse Trait::static_method { |
| 7 | 7 | | ------------- generic parameter used in this inner delegated function |
| 8 | LL | | |
| 8 | ... | |
| 9 | 9 | LL | let _ = T::Default(); |
| 10 | 10 | | ^ use of generic parameter from outer item |
| 11 | 11 | | |
| 12 | 12 | = note: nested items are independent from their parent item for everything except for privacy and name resolution |
| 13 | 13 | |
| 14 | 14 | error[E0434]: can't capture dynamic environment in a fn item |
| 15 | --> $DIR/target-expr.rs:25:17 | |
| 15 | --> $DIR/target-expr.rs:28:17 | |
| 16 | 16 | | |
| 17 | 17 | LL | let x = y; |
| 18 | 18 | | ^ |
| ... | ... | @@ -20,7 +20,7 @@ LL | let x = y; |
| 20 | 20 | = help: use the `|| { ... }` closure form instead |
| 21 | 21 | |
| 22 | 22 | error[E0424]: expected value, found module `self` |
| 23 | --> $DIR/target-expr.rs:32:5 | |
| 23 | --> $DIR/target-expr.rs:35:5 | |
| 24 | 24 | | |
| 25 | 25 | LL | fn main() { |
| 26 | 26 | | ---- this function can't have a `self` parameter |
| ... | ... | @@ -29,29 +29,38 @@ LL | self.0; |
| 29 | 29 | | ^^^^ `self` value is a keyword only available in methods with a `self` parameter |
| 30 | 30 | |
| 31 | 31 | error[E0425]: cannot find value `x` in this scope |
| 32 | --> $DIR/target-expr.rs:34:13 | |
| 32 | --> $DIR/target-expr.rs:37:13 | |
| 33 | 33 | | |
| 34 | 34 | LL | let z = x; |
| 35 | 35 | | ^ |
| 36 | 36 | | |
| 37 | 37 | help: the binding `x` is available in a different scope in the same function |
| 38 | --> $DIR/target-expr.rs:25:13 | |
| 38 | --> $DIR/target-expr.rs:28:13 | |
| 39 | 39 | | |
| 40 | 40 | LL | let x = y; |
| 41 | 41 | | ^ |
| 42 | 42 | |
| 43 | error: delegation self type is not specified | |
| 44 | --> $DIR/target-expr.rs:17:18 | |
| 45 | | | |
| 46 | LL | reuse Trait::static_method { | |
| 47 | | ^^^^^^^^^^^^^ | |
| 48 | | | |
| 49 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 50 | ||
| 43 | 51 | error[E0308]: mismatched types |
| 44 | --> $DIR/target-expr.rs:15:32 | |
| 52 | --> $DIR/target-expr.rs:17:32 | |
| 45 | 53 | | |
| 46 | 54 | LL | reuse Trait::static_method { |
| 47 | 55 | | ________________________________^ |
| 48 | 56 | LL | | |
| 57 | LL | | | |
| 49 | 58 | LL | | let _ = T::Default(); |
| 50 | 59 | LL | | |
| 51 | 60 | LL | | } |
| 52 | 61 | | |_____^ expected `i32`, found `()` |
| 53 | 62 | |
| 54 | error: aborting due to 5 previous errors | |
| 63 | error: aborting due to 6 previous errors | |
| 55 | 64 | |
| 56 | 65 | Some errors have detailed explanations: E0308, E0401, E0424, E0425, E0434. |
| 57 | 66 | For more information about an error, try `rustc --explain E0308`. |
tests/ui/delegation/unsupported.current.stderr+21-13| ... | ... | @@ -1,41 +1,49 @@ |
| 1 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}` | |
| 2 | --> $DIR/unsupported.rs:29:25 | |
| 1 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}` | |
| 2 | --> $DIR/unsupported.rs:30:25 | |
| 3 | 3 | | |
| 4 | 4 | LL | reuse to_reuse::opaque_ret; |
| 5 | 5 | | ^^^^^^^^^^ |
| 6 | 6 | | |
| 7 | 7 | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... |
| 8 | --> $DIR/unsupported.rs:29:25 | |
| 8 | --> $DIR/unsupported.rs:30:25 | |
| 9 | 9 | | |
| 10 | 10 | LL | reuse to_reuse::opaque_ret; |
| 11 | 11 | | ^^^^^^^^^^ |
| 12 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 13 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret` is compatible with trait definition | |
| 14 | --> $DIR/unsupported.rs:29:25 | |
| 12 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 13 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret` is compatible with trait definition | |
| 14 | --> $DIR/unsupported.rs:30:25 | |
| 15 | 15 | | |
| 16 | 16 | LL | reuse to_reuse::opaque_ret; |
| 17 | 17 | | ^^^^^^^^^^ |
| 18 | 18 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information |
| 19 | 19 | |
| 20 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}` | |
| 21 | --> $DIR/unsupported.rs:32:24 | |
| 20 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}` | |
| 21 | --> $DIR/unsupported.rs:33:24 | |
| 22 | 22 | | |
| 23 | 23 | LL | reuse ToReuse::opaque_ret; |
| 24 | 24 | | ^^^^^^^^^^ |
| 25 | 25 | | |
| 26 | 26 | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... |
| 27 | --> $DIR/unsupported.rs:32:24 | |
| 27 | --> $DIR/unsupported.rs:33:24 | |
| 28 | 28 | | |
| 29 | 29 | LL | reuse ToReuse::opaque_ret; |
| 30 | 30 | | ^^^^^^^^^^ |
| 31 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 32 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret` is compatible with trait definition | |
| 33 | --> $DIR/unsupported.rs:32:24 | |
| 31 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 32 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret` is compatible with trait definition | |
| 33 | --> $DIR/unsupported.rs:33:24 | |
| 34 | 34 | | |
| 35 | 35 | LL | reuse ToReuse::opaque_ret; |
| 36 | 36 | | ^^^^^^^^^^ |
| 37 | 37 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information |
| 38 | 38 | |
| 39 | error: aborting due to 2 previous errors | |
| 39 | error: delegation self type is not specified | |
| 40 | --> $DIR/unsupported.rs:54:18 | |
| 41 | | | |
| 42 | LL | reuse Trait::foo; | |
| 43 | | ^^^ | |
| 44 | | | |
| 45 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 46 | ||
| 47 | error: aborting due to 3 previous errors | |
| 40 | 48 | |
| 41 | 49 | For more information about this error, try `rustc --explain E0391`. |
tests/ui/delegation/unsupported.next.stderr+21-13| ... | ... | @@ -1,41 +1,49 @@ |
| 1 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}` | |
| 2 | --> $DIR/unsupported.rs:29:25 | |
| 1 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}` | |
| 2 | --> $DIR/unsupported.rs:30:25 | |
| 3 | 3 | | |
| 4 | 4 | LL | reuse to_reuse::opaque_ret; |
| 5 | 5 | | ^^^^^^^^^^ |
| 6 | 6 | | |
| 7 | 7 | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... |
| 8 | --> $DIR/unsupported.rs:29:25 | |
| 8 | --> $DIR/unsupported.rs:30:25 | |
| 9 | 9 | | |
| 10 | 10 | LL | reuse to_reuse::opaque_ret; |
| 11 | 11 | | ^^^^^^^^^^ |
| 12 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 13 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:28:5: 28:24>::opaque_ret` is compatible with trait definition | |
| 14 | --> $DIR/unsupported.rs:29:25 | |
| 12 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 13 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:29:5: 29:24>::opaque_ret` is compatible with trait definition | |
| 14 | --> $DIR/unsupported.rs:30:25 | |
| 15 | 15 | | |
| 16 | 16 | LL | reuse to_reuse::opaque_ret; |
| 17 | 17 | | ^^^^^^^^^^ |
| 18 | 18 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information |
| 19 | 19 | |
| 20 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}` | |
| 21 | --> $DIR/unsupported.rs:32:24 | |
| 20 | error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}` | |
| 21 | --> $DIR/unsupported.rs:33:24 | |
| 22 | 22 | | |
| 23 | 23 | LL | reuse ToReuse::opaque_ret; |
| 24 | 24 | | ^^^^^^^^^^ |
| 25 | 25 | | |
| 26 | 26 | note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process... |
| 27 | --> $DIR/unsupported.rs:32:24 | |
| 27 | --> $DIR/unsupported.rs:33:24 | |
| 28 | 28 | | |
| 29 | 29 | LL | reuse ToReuse::opaque_ret; |
| 30 | 30 | | ^^^^^^^^^^ |
| 31 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 32 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:31:5: 31:25>::opaque_ret` is compatible with trait definition | |
| 33 | --> $DIR/unsupported.rs:32:24 | |
| 31 | = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret::{anon_assoc#0}`, completing the cycle | |
| 32 | note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:32:5: 32:25>::opaque_ret` is compatible with trait definition | |
| 33 | --> $DIR/unsupported.rs:33:24 | |
| 34 | 34 | | |
| 35 | 35 | LL | reuse ToReuse::opaque_ret; |
| 36 | 36 | | ^^^^^^^^^^ |
| 37 | 37 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information |
| 38 | 38 | |
| 39 | error: aborting due to 2 previous errors | |
| 39 | error: delegation self type is not specified | |
| 40 | --> $DIR/unsupported.rs:54:18 | |
| 41 | | | |
| 42 | LL | reuse Trait::foo; | |
| 43 | | ^^^ | |
| 44 | | | |
| 45 | = help: consider explicitly specifying self type: `reuse </* Type */ as Trait>::function` | |
| 46 | ||
| 47 | error: aborting due to 3 previous errors | |
| 40 | 48 | |
| 41 | 49 | For more information about this error, try `rustc --explain E0391`. |
tests/ui/delegation/unsupported.rs+2| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | //@ compile-flags: -Z deduplicate-diagnostics=yes | |
| 1 | 2 | //@ revisions: current next |
| 2 | 3 | //@ ignore-compare-mode-next-solver (explicit revisions) |
| 3 | 4 | //@[next] compile-flags: -Znext-solver |
| ... | ... | @@ -51,6 +52,7 @@ mod effects { |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | 54 | reuse Trait::foo; |
| 55 | //~^ ERROR: delegation self type is not specified | |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | fn main() {} |
tests/ui/dropck/unconstrained_const_param_on_drop.stderr+4-1| ... | ... | @@ -22,7 +22,10 @@ error[E0207]: the const parameter `UNUSED` is not constrained by the impl trait, |
| 22 | 22 | --> $DIR/unconstrained_const_param_on_drop.rs:3:6 |
| 23 | 23 | | |
| 24 | 24 | LL | impl<const UNUSED: usize> Drop for Foo {} |
| 25 | | ^^^^^^^^^^^^^^^^^^^ unconstrained const parameter | |
| 25 | | -^^^^^^^^^^^^^^^^^^^- | |
| 26 | | || | |
| 27 | | |unconstrained const parameter | |
| 28 | | help: remove the unused type parameter `UNUSED` | |
| 26 | 29 | | |
| 27 | 30 | = note: expressions using a const parameter must map each value to a distinct output value |
| 28 | 31 | = note: proving the result of expressions other than the parameter are unique is not supported |
tests/ui/eii/dylib_needs_impl.rs created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | //@ no-prefer-dynamic | |
| 2 | //@ needs-crate-type: dylib | |
| 3 | #![crate_type = "dylib"] | |
| 4 | #![feature(extern_item_impls)] | |
| 5 | ||
| 6 | #[eii(eii1)] //~ ERROR `#[eii1]` required, but not found | |
| 7 | fn decl1(x: u64); |
tests/ui/eii/dylib_needs_impl.stderr created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | error: `#[eii1]` required, but not found | |
| 2 | --> $DIR/dylib_needs_impl.rs:6:7 | |
| 3 | | | |
| 4 | LL | #[eii(eii1)] | |
| 5 | | ^^^^ expected because `#[eii1]` was declared here in crate `dylib_needs_impl` | |
| 6 | | | |
| 7 | = help: expected at least one implementation in crate `dylib_needs_impl` or any of its dependencies | |
| 8 | ||
| 9 | error: aborting due to 1 previous error | |
| 10 |
tests/ui/error-codes/E0207.stderr+7| ... | ... | @@ -3,6 +3,13 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T: Default> Foo { |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `Foo` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Foo<T>; | |
| 10 | LL | | |
| 11 | LL ~ impl<T: Default> Foo<T> { | |
| 12 | | | |
| 6 | 13 | |
| 7 | 14 | error: aborting due to 1 previous error |
| 8 | 15 |
tests/ui/feature-gates/feature-gate-pin_ergonomics.rs+8| ... | ... | @@ -17,6 +17,14 @@ impl Drop for Foo { |
| 17 | 17 | //~^ ERROR use of unstable library feature `pin_ergonomics` [E0658] |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | struct Sugar; | |
| 21 | ||
| 22 | impl Drop for Sugar { | |
| 23 | //~^ ERROR not all trait items implemented, missing: `drop` | |
| 24 | fn drop(&pin mut self) {} //~ ERROR pinned reference syntax is experimental | |
| 25 | //~^ ERROR use of unstable library feature `pin_ergonomics` [E0658] | |
| 26 | } | |
| 27 | ||
| 20 | 28 | fn foo(mut x: Pin<&mut Foo>) { |
| 21 | 29 | Foo::foo_sugar(x.as_mut()); |
| 22 | 30 | Foo::foo_sugar_const(x.as_ref()); |
tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr+58-30| ... | ... | @@ -29,7 +29,17 @@ LL | fn pin_drop(&pin mut self) {} |
| 29 | 29 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 30 | 30 | |
| 31 | 31 | error[E0658]: pinned reference syntax is experimental |
| 32 | --> $DIR/feature-gate-pin_ergonomics.rs:23:14 | |
| 32 | --> $DIR/feature-gate-pin_ergonomics.rs:24:14 | |
| 33 | | | |
| 34 | LL | fn drop(&pin mut self) {} | |
| 35 | | ^^^ | |
| 36 | | | |
| 37 | = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information | |
| 38 | = help: add `#![feature(pin_ergonomics)]` to the crate attributes to enable | |
| 39 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | |
| 40 | ||
| 41 | error[E0658]: pinned reference syntax is experimental | |
| 42 | --> $DIR/feature-gate-pin_ergonomics.rs:31:14 | |
| 33 | 43 | | |
| 34 | 44 | LL | let _y: &pin mut Foo = x; |
| 35 | 45 | | ^^^ |
| ... | ... | @@ -39,7 +49,7 @@ LL | let _y: &pin mut Foo = x; |
| 39 | 49 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 40 | 50 | |
| 41 | 51 | error[E0658]: pinned reference syntax is experimental |
| 42 | --> $DIR/feature-gate-pin_ergonomics.rs:27:14 | |
| 52 | --> $DIR/feature-gate-pin_ergonomics.rs:35:14 | |
| 43 | 53 | | |
| 44 | 54 | LL | let _y: &pin const Foo = x; |
| 45 | 55 | | ^^^ |
| ... | ... | @@ -49,7 +59,7 @@ LL | let _y: &pin const Foo = x; |
| 49 | 59 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 50 | 60 | |
| 51 | 61 | error[E0658]: pinned reference syntax is experimental |
| 52 | --> $DIR/feature-gate-pin_ergonomics.rs:30:18 | |
| 62 | --> $DIR/feature-gate-pin_ergonomics.rs:38:18 | |
| 53 | 63 | | |
| 54 | 64 | LL | fn foo_sugar(_: &pin mut Foo) {} |
| 55 | 65 | | ^^^ |
| ... | ... | @@ -59,7 +69,7 @@ LL | fn foo_sugar(_: &pin mut Foo) {} |
| 59 | 69 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 60 | 70 | |
| 61 | 71 | error[E0658]: pinned reference syntax is experimental |
| 62 | --> $DIR/feature-gate-pin_ergonomics.rs:42:18 | |
| 72 | --> $DIR/feature-gate-pin_ergonomics.rs:50:18 | |
| 63 | 73 | | |
| 64 | 74 | LL | fn baz_sugar(_: &pin const Foo) {} |
| 65 | 75 | | ^^^ |
| ... | ... | @@ -69,7 +79,7 @@ LL | fn baz_sugar(_: &pin const Foo) {} |
| 69 | 79 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 70 | 80 | |
| 71 | 81 | error[E0658]: pinned reference syntax is experimental |
| 72 | --> $DIR/feature-gate-pin_ergonomics.rs:45:31 | |
| 82 | --> $DIR/feature-gate-pin_ergonomics.rs:53:31 | |
| 73 | 83 | | |
| 74 | 84 | LL | let mut x: Pin<&mut _> = &pin mut Foo; |
| 75 | 85 | | ^^^ |
| ... | ... | @@ -79,7 +89,7 @@ LL | let mut x: Pin<&mut _> = &pin mut Foo; |
| 79 | 89 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 80 | 90 | |
| 81 | 91 | error[E0658]: pinned reference syntax is experimental |
| 82 | --> $DIR/feature-gate-pin_ergonomics.rs:50:23 | |
| 92 | --> $DIR/feature-gate-pin_ergonomics.rs:58:23 | |
| 83 | 93 | | |
| 84 | 94 | LL | let x: Pin<&_> = &pin const Foo; |
| 85 | 95 | | ^^^ |
| ... | ... | @@ -89,7 +99,7 @@ LL | let x: Pin<&_> = &pin const Foo; |
| 89 | 99 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 90 | 100 | |
| 91 | 101 | error[E0658]: pinned reference syntax is experimental |
| 92 | --> $DIR/feature-gate-pin_ergonomics.rs:57:6 | |
| 102 | --> $DIR/feature-gate-pin_ergonomics.rs:65:6 | |
| 93 | 103 | | |
| 94 | 104 | LL | &pin mut x: &pin mut i32, |
| 95 | 105 | | ^^^ |
| ... | ... | @@ -99,7 +109,7 @@ LL | &pin mut x: &pin mut i32, |
| 99 | 109 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 100 | 110 | |
| 101 | 111 | error[E0658]: pinned reference syntax is experimental |
| 102 | --> $DIR/feature-gate-pin_ergonomics.rs:57:18 | |
| 112 | --> $DIR/feature-gate-pin_ergonomics.rs:65:18 | |
| 103 | 113 | | |
| 104 | 114 | LL | &pin mut x: &pin mut i32, |
| 105 | 115 | | ^^^ |
| ... | ... | @@ -109,7 +119,7 @@ LL | &pin mut x: &pin mut i32, |
| 109 | 119 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 110 | 120 | |
| 111 | 121 | error[E0658]: pinned reference syntax is experimental |
| 112 | --> $DIR/feature-gate-pin_ergonomics.rs:60:6 | |
| 122 | --> $DIR/feature-gate-pin_ergonomics.rs:68:6 | |
| 113 | 123 | | |
| 114 | 124 | LL | &pin const y: &'a pin const i32, |
| 115 | 125 | | ^^^ |
| ... | ... | @@ -119,7 +129,7 @@ LL | &pin const y: &'a pin const i32, |
| 119 | 129 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 120 | 130 | |
| 121 | 131 | error[E0658]: pinned reference syntax is experimental |
| 122 | --> $DIR/feature-gate-pin_ergonomics.rs:60:23 | |
| 132 | --> $DIR/feature-gate-pin_ergonomics.rs:68:23 | |
| 123 | 133 | | |
| 124 | 134 | LL | &pin const y: &'a pin const i32, |
| 125 | 135 | | ^^^ |
| ... | ... | @@ -129,7 +139,7 @@ LL | &pin const y: &'a pin const i32, |
| 129 | 139 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 130 | 140 | |
| 131 | 141 | error[E0658]: pinned reference syntax is experimental |
| 132 | --> $DIR/feature-gate-pin_ergonomics.rs:63:9 | |
| 142 | --> $DIR/feature-gate-pin_ergonomics.rs:71:9 | |
| 133 | 143 | | |
| 134 | 144 | LL | ref pin mut z: i32, |
| 135 | 145 | | ^^^ |
| ... | ... | @@ -139,7 +149,7 @@ LL | ref pin mut z: i32, |
| 139 | 149 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 140 | 150 | |
| 141 | 151 | error[E0658]: pinned reference syntax is experimental |
| 142 | --> $DIR/feature-gate-pin_ergonomics.rs:64:9 | |
| 152 | --> $DIR/feature-gate-pin_ergonomics.rs:72:9 | |
| 143 | 153 | | |
| 144 | 154 | LL | ref pin const w: i32, |
| 145 | 155 | | ^^^ |
| ... | ... | @@ -149,7 +159,7 @@ LL | ref pin const w: i32, |
| 149 | 159 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 150 | 160 | |
| 151 | 161 | error[E0658]: pinned reference syntax is experimental |
| 152 | --> $DIR/feature-gate-pin_ergonomics.rs:76:23 | |
| 162 | --> $DIR/feature-gate-pin_ergonomics.rs:84:23 | |
| 153 | 163 | | |
| 154 | 164 | LL | fn foo_sugar(&pin mut self) {} |
| 155 | 165 | | ^^^ |
| ... | ... | @@ -159,7 +169,7 @@ LL | fn foo_sugar(&pin mut self) {} |
| 159 | 169 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 160 | 170 | |
| 161 | 171 | error[E0658]: pinned reference syntax is experimental |
| 162 | --> $DIR/feature-gate-pin_ergonomics.rs:77:29 | |
| 172 | --> $DIR/feature-gate-pin_ergonomics.rs:85:29 | |
| 163 | 173 | | |
| 164 | 174 | LL | fn foo_sugar_const(&pin const self) {} |
| 165 | 175 | | ^^^ |
| ... | ... | @@ -169,7 +179,7 @@ LL | fn foo_sugar_const(&pin const self) {} |
| 169 | 179 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 170 | 180 | |
| 171 | 181 | error[E0658]: pinned reference syntax is experimental |
| 172 | --> $DIR/feature-gate-pin_ergonomics.rs:81:22 | |
| 182 | --> $DIR/feature-gate-pin_ergonomics.rs:89:22 | |
| 173 | 183 | | |
| 174 | 184 | LL | fn pin_drop(&pin mut self) {} |
| 175 | 185 | | ^^^ |
| ... | ... | @@ -179,7 +189,7 @@ LL | fn pin_drop(&pin mut self) {} |
| 179 | 189 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 180 | 190 | |
| 181 | 191 | error[E0658]: pinned reference syntax is experimental |
| 182 | --> $DIR/feature-gate-pin_ergonomics.rs:87:18 | |
| 192 | --> $DIR/feature-gate-pin_ergonomics.rs:95:18 | |
| 183 | 193 | | |
| 184 | 194 | LL | let _y: &pin mut Foo = x; |
| 185 | 195 | | ^^^ |
| ... | ... | @@ -189,7 +199,7 @@ LL | let _y: &pin mut Foo = x; |
| 189 | 199 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 190 | 200 | |
| 191 | 201 | error[E0658]: pinned reference syntax is experimental |
| 192 | --> $DIR/feature-gate-pin_ergonomics.rs:90:22 | |
| 202 | --> $DIR/feature-gate-pin_ergonomics.rs:98:22 | |
| 193 | 203 | | |
| 194 | 204 | LL | fn foo_sugar(_: &pin mut Foo) {} |
| 195 | 205 | | ^^^ |
| ... | ... | @@ -199,7 +209,7 @@ LL | fn foo_sugar(_: &pin mut Foo) {} |
| 199 | 209 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 200 | 210 | |
| 201 | 211 | error[E0658]: pinned reference syntax is experimental |
| 202 | --> $DIR/feature-gate-pin_ergonomics.rs:102:22 | |
| 212 | --> $DIR/feature-gate-pin_ergonomics.rs:110:22 | |
| 203 | 213 | | |
| 204 | 214 | LL | fn baz_sugar(_: &pin const Foo) {} |
| 205 | 215 | | ^^^ |
| ... | ... | @@ -209,7 +219,7 @@ LL | fn baz_sugar(_: &pin const Foo) {} |
| 209 | 219 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 210 | 220 | |
| 211 | 221 | error[E0658]: pinned reference syntax is experimental |
| 212 | --> $DIR/feature-gate-pin_ergonomics.rs:105:35 | |
| 222 | --> $DIR/feature-gate-pin_ergonomics.rs:113:35 | |
| 213 | 223 | | |
| 214 | 224 | LL | let mut x: Pin<&mut _> = &pin mut Foo; |
| 215 | 225 | | ^^^ |
| ... | ... | @@ -219,7 +229,7 @@ LL | let mut x: Pin<&mut _> = &pin mut Foo; |
| 219 | 229 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 220 | 230 | |
| 221 | 231 | error[E0658]: pinned reference syntax is experimental |
| 222 | --> $DIR/feature-gate-pin_ergonomics.rs:110:27 | |
| 232 | --> $DIR/feature-gate-pin_ergonomics.rs:118:27 | |
| 223 | 233 | | |
| 224 | 234 | LL | let x: Pin<&_> = &pin const Foo; |
| 225 | 235 | | ^^^ |
| ... | ... | @@ -229,7 +239,7 @@ LL | let x: Pin<&_> = &pin const Foo; |
| 229 | 239 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 230 | 240 | |
| 231 | 241 | error[E0658]: pinned reference syntax is experimental |
| 232 | --> $DIR/feature-gate-pin_ergonomics.rs:117:10 | |
| 242 | --> $DIR/feature-gate-pin_ergonomics.rs:125:10 | |
| 233 | 243 | | |
| 234 | 244 | LL | &pin mut x: &pin mut i32, |
| 235 | 245 | | ^^^ |
| ... | ... | @@ -239,7 +249,7 @@ LL | &pin mut x: &pin mut i32, |
| 239 | 249 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 240 | 250 | |
| 241 | 251 | error[E0658]: pinned reference syntax is experimental |
| 242 | --> $DIR/feature-gate-pin_ergonomics.rs:117:22 | |
| 252 | --> $DIR/feature-gate-pin_ergonomics.rs:125:22 | |
| 243 | 253 | | |
| 244 | 254 | LL | &pin mut x: &pin mut i32, |
| 245 | 255 | | ^^^ |
| ... | ... | @@ -249,7 +259,7 @@ LL | &pin mut x: &pin mut i32, |
| 249 | 259 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 250 | 260 | |
| 251 | 261 | error[E0658]: pinned reference syntax is experimental |
| 252 | --> $DIR/feature-gate-pin_ergonomics.rs:120:10 | |
| 262 | --> $DIR/feature-gate-pin_ergonomics.rs:128:10 | |
| 253 | 263 | | |
| 254 | 264 | LL | &pin const y: &'a pin const i32, |
| 255 | 265 | | ^^^ |
| ... | ... | @@ -259,7 +269,7 @@ LL | &pin const y: &'a pin const i32, |
| 259 | 269 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 260 | 270 | |
| 261 | 271 | error[E0658]: pinned reference syntax is experimental |
| 262 | --> $DIR/feature-gate-pin_ergonomics.rs:120:27 | |
| 272 | --> $DIR/feature-gate-pin_ergonomics.rs:128:27 | |
| 263 | 273 | | |
| 264 | 274 | LL | &pin const y: &'a pin const i32, |
| 265 | 275 | | ^^^ |
| ... | ... | @@ -269,7 +279,7 @@ LL | &pin const y: &'a pin const i32, |
| 269 | 279 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 270 | 280 | |
| 271 | 281 | error[E0658]: pinned reference syntax is experimental |
| 272 | --> $DIR/feature-gate-pin_ergonomics.rs:123:13 | |
| 282 | --> $DIR/feature-gate-pin_ergonomics.rs:131:13 | |
| 273 | 283 | | |
| 274 | 284 | LL | ref pin mut z: i32, |
| 275 | 285 | | ^^^ |
| ... | ... | @@ -279,7 +289,7 @@ LL | ref pin mut z: i32, |
| 279 | 289 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 280 | 290 | |
| 281 | 291 | error[E0658]: pinned reference syntax is experimental |
| 282 | --> $DIR/feature-gate-pin_ergonomics.rs:124:13 | |
| 292 | --> $DIR/feature-gate-pin_ergonomics.rs:132:13 | |
| 283 | 293 | | |
| 284 | 294 | LL | ref pin const w: i32, |
| 285 | 295 | | ^^^ |
| ... | ... | @@ -308,6 +318,16 @@ LL | fn pin_drop(&pin mut self) {} |
| 308 | 318 | = help: add `#![feature(pin_ergonomics)]` to the crate attributes to enable |
| 309 | 319 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date |
| 310 | 320 | |
| 321 | error[E0658]: use of unstable library feature `pin_ergonomics` | |
| 322 | --> $DIR/feature-gate-pin_ergonomics.rs:24:5 | |
| 323 | | | |
| 324 | LL | fn drop(&pin mut self) {} | |
| 325 | | ^^^^^^^^^^^^^^^^^^^^^^ | |
| 326 | | | |
| 327 | = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information | |
| 328 | = help: add `#![feature(pin_ergonomics)]` to the crate attributes to enable | |
| 329 | = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | |
| 330 | ||
| 311 | 331 | error[E0046]: not all trait items implemented, missing: `drop` |
| 312 | 332 | --> $DIR/feature-gate-pin_ergonomics.rs:14:1 |
| 313 | 333 | | |
| ... | ... | @@ -316,8 +336,16 @@ LL | impl Drop for Foo { |
| 316 | 336 | | |
| 317 | 337 | = help: implement the missing item: `fn drop(&mut self) { todo!() }` |
| 318 | 338 | |
| 339 | error[E0046]: not all trait items implemented, missing: `drop` | |
| 340 | --> $DIR/feature-gate-pin_ergonomics.rs:22:1 | |
| 341 | | | |
| 342 | LL | impl Drop for Sugar { | |
| 343 | | ^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation | |
| 344 | | | |
| 345 | = help: implement the missing item: `fn drop(&mut self) { todo!() }` | |
| 346 | ||
| 319 | 347 | error[E0382]: use of moved value: `x` |
| 320 | --> $DIR/feature-gate-pin_ergonomics.rs:34:9 | |
| 348 | --> $DIR/feature-gate-pin_ergonomics.rs:42:9 | |
| 321 | 349 | | |
| 322 | 350 | LL | fn bar(x: Pin<&mut Foo>) { |
| 323 | 351 | | - move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait |
| ... | ... | @@ -327,7 +355,7 @@ LL | foo(x); |
| 327 | 355 | | ^ value used here after move |
| 328 | 356 | | |
| 329 | 357 | note: consider changing this parameter type in function `foo` to borrow instead if owning the value isn't necessary |
| 330 | --> $DIR/feature-gate-pin_ergonomics.rs:20:15 | |
| 358 | --> $DIR/feature-gate-pin_ergonomics.rs:28:15 | |
| 331 | 359 | | |
| 332 | 360 | LL | fn foo(mut x: Pin<&mut Foo>) { |
| 333 | 361 | | --- ^^^^^^^^^^^^^ this parameter takes ownership of the value |
| ... | ... | @@ -335,7 +363,7 @@ LL | fn foo(mut x: Pin<&mut Foo>) { |
| 335 | 363 | | in this function |
| 336 | 364 | |
| 337 | 365 | error[E0382]: use of moved value: `x` |
| 338 | --> $DIR/feature-gate-pin_ergonomics.rs:39:5 | |
| 366 | --> $DIR/feature-gate-pin_ergonomics.rs:47:5 | |
| 339 | 367 | | |
| 340 | 368 | LL | fn baz(mut x: Pin<&mut Foo>) { |
| 341 | 369 | | ----- move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait |
| ... | ... | @@ -354,7 +382,7 @@ help: consider reborrowing the `Pin` instead of moving it |
| 354 | 382 | LL | x.as_mut().foo(); |
| 355 | 383 | | +++++++++ |
| 356 | 384 | |
| 357 | error: aborting due to 34 previous errors | |
| 385 | error: aborting due to 37 previous errors | |
| 358 | 386 | |
| 359 | 387 | Some errors have detailed explanations: E0046, E0382, E0658. |
| 360 | 388 | For more information about an error, try `rustc --explain E0046`. |
tests/ui/generic-associated-types/bugs/issue-87735.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<'b, T, U> AsRef2 for Foo<T> |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `U` in the `Foo` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Foo<T, U>(T); | |
| 10 | LL | #[derive(Debug)] | |
| 11 | LL | struct FooRef<'a, U>(&'a [U]); | |
| 12 | LL | | |
| 13 | LL ~ impl<'b, T, U> AsRef2 for Foo<T, U> | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error[E0309]: the parameter type `U` may not live long enough |
| 8 | 17 | --> $DIR/issue-87735.rs:34:3 |
tests/ui/generic-associated-types/bugs/issue-88526.stderr+4-1| ... | ... | @@ -2,7 +2,10 @@ error[E0207]: the type parameter `I` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/issue-88526.rs:25:13 |
| 3 | 3 | | |
| 4 | 4 | LL | impl<'q, Q, I, F> A for TestB<Q, F> |
| 5 | | ^ unconstrained type parameter | |
| 5 | | ^-- | |
| 6 | | | | |
| 7 | | unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `I` | |
| 6 | 9 | |
| 7 | 10 | error[E0309]: the parameter type `F` may not live long enough |
| 8 | 11 | --> $DIR/issue-88526.rs:16:5 |
tests/ui/generics/unconstrained-param-default-available.rs created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | //! Test that making use of parameter is suggested when a parameter with default type is available | |
| 2 | ||
| 3 | struct S<U = i32> { | |
| 4 | _u: U, | |
| 5 | } | |
| 6 | impl<V> MyTrait for S {} | |
| 7 | //~^ ERROR the type parameter `V` is not constrained by the impl trait, self type, or predicates | |
| 8 | ||
| 9 | struct S2<T, U = i32> { | |
| 10 | _t: T, | |
| 11 | _u: U, | |
| 12 | } | |
| 13 | impl<T, V> MyTrait for S2<T> {} | |
| 14 | //~^ ERROR the type parameter `V` is not constrained by the impl trait, self type, or predicates | |
| 15 | ||
| 16 | trait MyTrait {} | |
| 17 | ||
| 18 | fn main() {} |
tests/ui/generics/unconstrained-param-default-available.stderr created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates | |
| 2 | --> $DIR/unconstrained-param-default-available.rs:6:6 | |
| 3 | | | |
| 4 | LL | impl<V> MyTrait for S {} | |
| 5 | | ^ unconstrained type parameter | |
| 6 | | | |
| 7 | help: either remove the unused type parameter `V` | |
| 8 | | | |
| 9 | LL - impl<V> MyTrait for S {} | |
| 10 | LL + impl MyTrait for S {} | |
| 11 | | | |
| 12 | help: or use it | |
| 13 | | | |
| 14 | LL | impl<V> MyTrait for S<V> {} | |
| 15 | | +++ | |
| 16 | ||
| 17 | error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates | |
| 18 | --> $DIR/unconstrained-param-default-available.rs:13:9 | |
| 19 | | | |
| 20 | LL | impl<T, V> MyTrait for S2<T> {} | |
| 21 | | ^ unconstrained type parameter | |
| 22 | | | |
| 23 | help: either remove the unused type parameter `V` | |
| 24 | | | |
| 25 | LL - impl<T, V> MyTrait for S2<T> {} | |
| 26 | LL + impl<T> MyTrait for S2<T> {} | |
| 27 | | | |
| 28 | help: or use it | |
| 29 | | | |
| 30 | LL | impl<T, V> MyTrait for S2<T, V> {} | |
| 31 | | +++ | |
| 32 | ||
| 33 | error: aborting due to 2 previous errors | |
| 34 | ||
| 35 | For more information about this error, try `rustc --explain E0207`. |
tests/ui/generics/unconstrained-type-params-inherent-impl.stderr+8-2| ... | ... | @@ -2,13 +2,19 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/unconstrained-type-params-inherent-impl.rs:11:6 |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T> MyType { |
| 5 | | ^ unconstrained type parameter | |
| 5 | | -^- | |
| 6 | | || | |
| 7 | | |unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `T` | |
| 6 | 9 | |
| 7 | 10 | error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates |
| 8 | 11 | --> $DIR/unconstrained-type-params-inherent-impl.rs:20:9 |
| 9 | 12 | | |
| 10 | 13 | LL | impl<T, U> MyType1<T> { |
| 11 | | ^ unconstrained type parameter | |
| 14 | | --^ | |
| 15 | | | | | |
| 16 | | | unconstrained type parameter | |
| 17 | | help: remove the unused type parameter `U` | |
| 12 | 18 | |
| 13 | 19 | error: aborting due to 2 previous errors |
| 14 | 20 |
tests/ui/generics/unconstrained-used-param.rs created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //! Test that making use of parameter is suggested when the parameter is used in the impl | |
| 2 | //! but not in the trait or self type | |
| 3 | ||
| 4 | struct S; | |
| 5 | impl<T> S { | |
| 6 | //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 7 | fn foo(&self, x: T) { | |
| 8 | // use T here | |
| 9 | } | |
| 10 | } | |
| 11 | ||
| 12 | ||
| 13 | struct S2<F> { | |
| 14 | _f: F, | |
| 15 | } | |
| 16 | impl<F, T> S2<F> { | |
| 17 | //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 18 | fn foo(&self, x: T) { | |
| 19 | // use T here | |
| 20 | } | |
| 21 | } | |
| 22 | ||
| 23 | fn main() {} |
tests/ui/generics/unconstrained-used-param.stderr created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 2 | --> $DIR/unconstrained-used-param.rs:5:6 | |
| 3 | | | |
| 4 | LL | impl<T> S { | |
| 5 | | ^ unconstrained type parameter | |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `S` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct S<T>; | |
| 10 | LL ~ impl<T> S<T> { | |
| 11 | | | |
| 12 | ||
| 13 | error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 14 | --> $DIR/unconstrained-used-param.rs:16:9 | |
| 15 | | | |
| 16 | LL | impl<F, T> S2<F> { | |
| 17 | | ^ unconstrained type parameter | |
| 18 | | | |
| 19 | help: use the type parameter `T` in the `S2` type and use it in the type definition | |
| 20 | | | |
| 21 | LL ~ struct S2<F, T> { | |
| 22 | LL | _f: F, | |
| 23 | LL | } | |
| 24 | LL ~ impl<F, T> S2<F, T> { | |
| 25 | | | |
| 26 | ||
| 27 | error: aborting due to 2 previous errors | |
| 28 | ||
| 29 | For more information about this error, try `rustc --explain E0207`. |
tests/ui/issues/issue-16562.stderr+4-1| ... | ... | @@ -2,7 +2,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/issue-16562.rs:10:6 |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T, M: MatrixShape> Collection for Col<M, usize> { |
| 5 | | ^ unconstrained type parameter | |
| 5 | | ^-- | |
| 6 | | | | |
| 7 | | unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `T` | |
| 6 | 9 | |
| 7 | 10 | error: aborting due to 1 previous error |
| 8 | 11 |
tests/ui/issues/issue-22886.stderr+7| ... | ... | @@ -3,6 +3,13 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, |
| 3 | 3 | | |
| 4 | 4 | LL | impl<'a> Iterator for Newtype { |
| 5 | 5 | | ^^ unconstrained lifetime parameter |
| 6 | | | |
| 7 | help: use the lifetime parameter `'a` in the `Newtype` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Newtype<'a>(Option<Box<usize>>); | |
| 10 | LL | | |
| 11 | LL ~ impl<'a> Iterator for Newtype<'a> { | |
| 12 | | | |
| 6 | 13 | |
| 7 | 14 | error: aborting due to 1 previous error |
| 8 | 15 |
tests/ui/issues/issue-35139.stderr+7| ... | ... | @@ -3,6 +3,13 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, |
| 3 | 3 | | |
| 4 | 4 | LL | impl<'a> MethodType for MTFn { |
| 5 | 5 | | ^^ unconstrained lifetime parameter |
| 6 | | | |
| 7 | help: use the lifetime parameter `'a` in the `MTFn` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ pub struct MTFn<'a>; | |
| 10 | LL | | |
| 11 | LL ~ impl<'a> MethodType for MTFn<'a> { | |
| 12 | | | |
| 6 | 13 | |
| 7 | 14 | error: aborting due to 1 previous error |
| 8 | 15 |
tests/ui/pin-ergonomics/pinned-drop-check.rs+83-5| ... | ... | @@ -25,11 +25,11 @@ mod pin_drop_only { |
| 25 | 25 | struct Bar; |
| 26 | 26 | |
| 27 | 27 | impl Drop for Foo { |
| 28 | fn pin_drop(&pin mut self) {} // ok, only `pin_drop` is implemented | |
| 28 | fn pin_drop(&pin mut self) {} // ok, non-`#[pin_v2]` can also implement `pin_drop` | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | impl Drop for Bar { |
| 32 | fn pin_drop(&pin mut self) {} // ok, non-`#[pin_v2]` can also implement `pin_drop` | |
| 32 | fn pin_drop(&pin mut self) {} // ok, `#[pin_v2]` implements `pin_drop` | |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| ... | ... | @@ -60,16 +60,67 @@ mod neither { |
| 60 | 60 | impl Drop for Bar {} //~ ERROR not all trait items implemented, missing one of: `drop`, `pin_drop` [E0046] |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | mod drop_wrong_type { | |
| 63 | mod drop_sugar { | |
| 64 | 64 | struct Foo; |
| 65 | 65 | #[pin_v2] |
| 66 | 66 | struct Bar; |
| 67 | 67 | |
| 68 | 68 | impl Drop for Foo { |
| 69 | fn drop(&pin mut self) {} //~ ERROR method `drop` has an incompatible type for trait [E0053] | |
| 69 | fn drop(&pin mut self) {} // ok, sugar for `pin_drop` | |
| 70 | 70 | } |
| 71 | ||
| 71 | 72 | impl Drop for Bar { |
| 72 | fn drop(&pin mut self) {} | |
| 73 | fn drop(&pin mut self) {} // ok, sugar for `pin_drop` | |
| 74 | } | |
| 75 | } | |
| 76 | ||
| 77 | mod drop_pin_const_wrong_type { | |
| 78 | struct Foo; | |
| 79 | #[pin_v2] | |
| 80 | struct Bar; | |
| 81 | ||
| 82 | impl Drop for Foo { | |
| 83 | fn drop(&pin const self) {} //~ ERROR method `drop` has an incompatible type for trait [E0053] | |
| 84 | } | |
| 85 | ||
| 86 | impl Drop for Bar { | |
| 87 | fn drop(&pin const self) {} | |
| 88 | //~^ ERROR method `drop` has an incompatible type for trait [E0053] | |
| 89 | //~| ERROR `Bar` must implement `pin_drop` | |
| 90 | } | |
| 91 | } | |
| 92 | ||
| 93 | mod drop_with_lifetime_wrong_type { | |
| 94 | struct Foo; | |
| 95 | #[pin_v2] | |
| 96 | struct Bar; | |
| 97 | ||
| 98 | impl Drop for Foo { | |
| 99 | fn drop<'a>(&'a pin mut self) {} | |
| 100 | //~^ ERROR method `drop` has an incompatible type for trait [E0053] | |
| 101 | } | |
| 102 | ||
| 103 | impl Drop for Bar { | |
| 104 | fn drop<'a>(&'a pin mut self) {} | |
| 105 | //~^ ERROR method `drop` has an incompatible type for trait [E0053] | |
| 106 | //~| ERROR `Bar` must implement `pin_drop` | |
| 107 | } | |
| 108 | } | |
| 109 | ||
| 110 | mod drop_explicit_pin_wrong_type { | |
| 111 | use std::pin::Pin; | |
| 112 | ||
| 113 | struct Foo; | |
| 114 | #[pin_v2] | |
| 115 | struct Bar; | |
| 116 | ||
| 117 | impl Drop for Foo { | |
| 118 | fn drop(self: Pin<&mut Self>) {} | |
| 119 | //~^ ERROR method `drop` has an incompatible type for trait [E0053] | |
| 120 | } | |
| 121 | ||
| 122 | impl Drop for Bar { | |
| 123 | fn drop(self: Pin<&mut Self>) {} | |
| 73 | 124 | //~^ ERROR method `drop` has an incompatible type for trait [E0053] |
| 74 | 125 | //~| ERROR `Bar` must implement `pin_drop` |
| 75 | 126 | } |
| ... | ... | @@ -124,4 +175,31 @@ mod explicit_call_drop { |
| 124 | 175 | } |
| 125 | 176 | } |
| 126 | 177 | |
| 178 | mod explicit_call_drop_sugar { | |
| 179 | struct Foo; | |
| 180 | ||
| 181 | impl Drop for Foo { | |
| 182 | fn drop(&pin mut self) { | |
| 183 | Drop::drop(todo!()); //~ ERROR explicit use of destructor method [E0040] | |
| 184 | Drop::pin_drop(todo!()); //~ ERROR explicit use of destructor method [E0040] | |
| 185 | } | |
| 186 | } | |
| 187 | } | |
| 188 | ||
| 189 | mod sugar_and_pin_drop { | |
| 190 | struct Foo; | |
| 191 | #[pin_v2] | |
| 192 | struct Bar; | |
| 193 | ||
| 194 | impl Drop for Foo { | |
| 195 | fn drop(&pin mut self) {} | |
| 196 | fn pin_drop(&pin mut self) {} //~ ERROR duplicate definitions with name `pin_drop` | |
| 197 | } | |
| 198 | ||
| 199 | impl Drop for Bar { | |
| 200 | fn drop(&pin mut self) {} | |
| 201 | fn pin_drop(&pin mut self) {} //~ ERROR duplicate definitions with name `pin_drop` | |
| 202 | } | |
| 203 | } | |
| 204 | ||
| 127 | 205 | fn main() {} |
tests/ui/pin-ergonomics/pinned-drop-check.stderr+165-28| ... | ... | @@ -1,3 +1,27 @@ |
| 1 | error[E0201]: duplicate definitions with name `pin_drop`: | |
| 2 | --> $DIR/pinned-drop-check.rs:196:9 | |
| 3 | | | |
| 4 | LL | fn drop(&pin mut self) {} | |
| 5 | | ------------------------- previous definition here | |
| 6 | LL | fn pin_drop(&pin mut self) {} | |
| 7 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition | |
| 8 | | | |
| 9 | --> $SRC_DIR/core/src/ops/drop.rs:LL:COL | |
| 10 | | | |
| 11 | = note: item in trait | |
| 12 | ||
| 13 | error[E0201]: duplicate definitions with name `pin_drop`: | |
| 14 | --> $DIR/pinned-drop-check.rs:201:9 | |
| 15 | | | |
| 16 | LL | fn drop(&pin mut self) {} | |
| 17 | | ------------------------- previous definition here | |
| 18 | LL | fn pin_drop(&pin mut self) {} | |
| 19 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition | |
| 20 | | | |
| 21 | --> $SRC_DIR/core/src/ops/drop.rs:LL:COL | |
| 22 | | | |
| 23 | = note: item in trait | |
| 24 | ||
| 1 | 25 | error: `Bar` must implement `pin_drop` |
| 2 | 26 | --> $DIR/pinned-drop-check.rs:18:9 |
| 3 | 27 | | |
| ... | ... | @@ -55,56 +79,157 @@ LL | impl Drop for Bar {} |
| 55 | 79 | | ^^^^^^^^^^^^^^^^^ missing one of `drop`, `pin_drop` in implementation |
| 56 | 80 | |
| 57 | 81 | error: `Bar` must implement `pin_drop` |
| 58 | --> $DIR/pinned-drop-check.rs:72:9 | |
| 82 | --> $DIR/pinned-drop-check.rs:87:9 | |
| 59 | 83 | | |
| 60 | LL | fn drop(&pin mut self) {} | |
| 61 | | ^^^^^^^^^^^^^^^^^^^^^^ | |
| 84 | LL | fn drop(&pin const self) {} | |
| 85 | | ^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 62 | 86 | | |
| 63 | 87 | = help: structurally pinned types must keep `Pin`'s safety contract |
| 64 | 88 | note: `Bar` is marked `#[pin_v2]` here |
| 65 | --> $DIR/pinned-drop-check.rs:65:5 | |
| 89 | --> $DIR/pinned-drop-check.rs:79:5 | |
| 66 | 90 | | |
| 67 | 91 | LL | #[pin_v2] |
| 68 | 92 | | ^^^^^^^^^ |
| 69 | 93 | help: implement `pin_drop` instead |
| 70 | 94 | | |
| 71 | LL | fn pin_drop(&pin mut self) {} | |
| 72 | | ++++ | |
| 95 | LL - fn drop(&pin const self) {} | |
| 96 | LL + fn pin_drop(&pin mut self) {} | |
| 97 | | | |
| 73 | 98 | help: remove the `#[pin_v2]` attribute if it is not intended for structurally pinning |
| 74 | 99 | | |
| 75 | 100 | LL - #[pin_v2] |
| 76 | 101 | | |
| 77 | 102 | |
| 78 | 103 | error[E0053]: method `drop` has an incompatible type for trait |
| 79 | --> $DIR/pinned-drop-check.rs:69:17 | |
| 104 | --> $DIR/pinned-drop-check.rs:83:17 | |
| 80 | 105 | | |
| 81 | LL | fn drop(&pin mut self) {} | |
| 82 | | ^^^^^^^^^^^^^ expected `&mut drop_wrong_type::Foo`, found `Pin<&mut drop_wrong_type::Foo>` | |
| 106 | LL | fn drop(&pin const self) {} | |
| 107 | | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Foo`, found `Pin<&drop_pin_const_wrong_type::Foo>` | |
| 83 | 108 | | |
| 84 | = note: expected signature `fn(&mut drop_wrong_type::Foo)` | |
| 85 | found signature `fn(Pin<&mut drop_wrong_type::Foo>)` | |
| 109 | = note: expected signature `fn(&mut drop_pin_const_wrong_type::Foo)` | |
| 110 | found signature `fn(Pin<&drop_pin_const_wrong_type::Foo>)` | |
| 86 | 111 | help: change the self-receiver type to match the trait |
| 87 | 112 | | |
| 88 | LL - fn drop(&pin mut self) {} | |
| 113 | LL - fn drop(&pin const self) {} | |
| 89 | 114 | LL + fn drop(&mut self) {} |
| 90 | 115 | | |
| 91 | 116 | |
| 92 | 117 | error[E0053]: method `drop` has an incompatible type for trait |
| 93 | --> $DIR/pinned-drop-check.rs:72:17 | |
| 118 | --> $DIR/pinned-drop-check.rs:87:17 | |
| 94 | 119 | | |
| 95 | LL | fn drop(&pin mut self) {} | |
| 96 | | ^^^^^^^^^^^^^ expected `&mut drop_wrong_type::Bar`, found `Pin<&mut drop_wrong_type::Bar>` | |
| 120 | LL | fn drop(&pin const self) {} | |
| 121 | | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Bar`, found `Pin<&drop_pin_const_wrong_type::Bar>` | |
| 122 | | | |
| 123 | = note: expected signature `fn(&mut drop_pin_const_wrong_type::Bar)` | |
| 124 | found signature `fn(Pin<&drop_pin_const_wrong_type::Bar>)` | |
| 125 | help: change the self-receiver type to match the trait | |
| 126 | | | |
| 127 | LL - fn drop(&pin const self) {} | |
| 128 | LL + fn drop(&mut self) {} | |
| 129 | | | |
| 130 | ||
| 131 | error: `Bar` must implement `pin_drop` | |
| 132 | --> $DIR/pinned-drop-check.rs:104:9 | |
| 133 | | | |
| 134 | LL | fn drop<'a>(&'a pin mut self) {} | |
| 135 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 136 | | | |
| 137 | = help: structurally pinned types must keep `Pin`'s safety contract | |
| 138 | note: `Bar` is marked `#[pin_v2]` here | |
| 139 | --> $DIR/pinned-drop-check.rs:95:5 | |
| 140 | | | |
| 141 | LL | #[pin_v2] | |
| 142 | | ^^^^^^^^^ | |
| 143 | help: implement `pin_drop` instead | |
| 144 | | | |
| 145 | LL - fn drop<'a>(&'a pin mut self) {} | |
| 146 | LL + fn pin_drop(&pin mut self) {} | |
| 147 | | | |
| 148 | help: remove the `#[pin_v2]` attribute if it is not intended for structurally pinning | |
| 149 | | | |
| 150 | LL - #[pin_v2] | |
| 151 | | | |
| 152 | ||
| 153 | error[E0053]: method `drop` has an incompatible type for trait | |
| 154 | --> $DIR/pinned-drop-check.rs:99:21 | |
| 155 | | | |
| 156 | LL | fn drop<'a>(&'a pin mut self) {} | |
| 157 | | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Foo`, found `Pin<&mut Foo>` | |
| 158 | | | |
| 159 | = note: expected signature `fn(&mut drop_with_lifetime_wrong_type::Foo)` | |
| 160 | found signature `fn(Pin<&mut drop_with_lifetime_wrong_type::Foo>)` | |
| 161 | help: change the self-receiver type to match the trait | |
| 162 | | | |
| 163 | LL - fn drop<'a>(&'a pin mut self) {} | |
| 164 | LL + fn drop<'a>(&mut self) {} | |
| 97 | 165 | | |
| 98 | = note: expected signature `fn(&mut drop_wrong_type::Bar)` | |
| 99 | found signature `fn(Pin<&mut drop_wrong_type::Bar>)` | |
| 166 | ||
| 167 | error[E0053]: method `drop` has an incompatible type for trait | |
| 168 | --> $DIR/pinned-drop-check.rs:104:21 | |
| 169 | | | |
| 170 | LL | fn drop<'a>(&'a pin mut self) {} | |
| 171 | | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Bar`, found `Pin<&mut Bar>` | |
| 172 | | | |
| 173 | = note: expected signature `fn(&mut drop_with_lifetime_wrong_type::Bar)` | |
| 174 | found signature `fn(Pin<&mut drop_with_lifetime_wrong_type::Bar>)` | |
| 175 | help: change the self-receiver type to match the trait | |
| 176 | | | |
| 177 | LL - fn drop<'a>(&'a pin mut self) {} | |
| 178 | LL + fn drop<'a>(&mut self) {} | |
| 179 | | | |
| 180 | ||
| 181 | error: `Bar` must implement `pin_drop` | |
| 182 | --> $DIR/pinned-drop-check.rs:123:9 | |
| 183 | | | |
| 184 | LL | fn drop(self: Pin<&mut Self>) {} | |
| 185 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 186 | | | |
| 187 | = help: structurally pinned types must keep `Pin`'s safety contract | |
| 188 | note: `Bar` is marked `#[pin_v2]` here | |
| 189 | --> $DIR/pinned-drop-check.rs:114:5 | |
| 190 | | | |
| 191 | LL | #[pin_v2] | |
| 192 | | ^^^^^^^^^ | |
| 193 | help: implement `pin_drop` instead | |
| 194 | | | |
| 195 | LL - fn drop(self: Pin<&mut Self>) {} | |
| 196 | LL + fn pin_drop(&pin mut self) {} | |
| 197 | | | |
| 198 | help: remove the `#[pin_v2]` attribute if it is not intended for structurally pinning | |
| 199 | | | |
| 200 | LL - #[pin_v2] | |
| 201 | | | |
| 202 | ||
| 203 | error[E0053]: method `drop` has an incompatible type for trait | |
| 204 | --> $DIR/pinned-drop-check.rs:118:23 | |
| 205 | | | |
| 206 | LL | fn drop(self: Pin<&mut Self>) {} | |
| 207 | | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Foo`, found `Pin<&mut Foo>` | |
| 208 | | | |
| 209 | = note: expected signature `fn(&mut drop_explicit_pin_wrong_type::Foo)` | |
| 210 | found signature `fn(Pin<&mut drop_explicit_pin_wrong_type::Foo>)` | |
| 100 | 211 | help: change the self-receiver type to match the trait |
| 101 | 212 | | |
| 102 | LL - fn drop(&pin mut self) {} | |
| 213 | LL - fn drop(self: Pin<&mut Self>) {} | |
| 214 | LL + fn drop(&mut self) {} | |
| 215 | | | |
| 216 | ||
| 217 | error[E0053]: method `drop` has an incompatible type for trait | |
| 218 | --> $DIR/pinned-drop-check.rs:123:23 | |
| 219 | | | |
| 220 | LL | fn drop(self: Pin<&mut Self>) {} | |
| 221 | | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Bar`, found `Pin<&mut Bar>` | |
| 222 | | | |
| 223 | = note: expected signature `fn(&mut drop_explicit_pin_wrong_type::Bar)` | |
| 224 | found signature `fn(Pin<&mut drop_explicit_pin_wrong_type::Bar>)` | |
| 225 | help: change the self-receiver type to match the trait | |
| 226 | | | |
| 227 | LL - fn drop(self: Pin<&mut Self>) {} | |
| 103 | 228 | LL + fn drop(&mut self) {} |
| 104 | 229 | | |
| 105 | 230 | |
| 106 | 231 | error[E0053]: method `pin_drop` has an incompatible type for trait |
| 107 | --> $DIR/pinned-drop-check.rs:84:21 | |
| 232 | --> $DIR/pinned-drop-check.rs:135:21 | |
| 108 | 233 | | |
| 109 | 234 | LL | fn pin_drop(&mut self) {} |
| 110 | 235 | | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Foo>`, found `&mut pin_drop_wrong_type::Foo` |
| ... | ... | @@ -118,7 +243,7 @@ LL + fn pin_drop(self: Pin<&mut pin_drop_wrong_type::Foo>) {} |
| 118 | 243 | | |
| 119 | 244 | |
| 120 | 245 | error[E0053]: method `pin_drop` has an incompatible type for trait |
| 121 | --> $DIR/pinned-drop-check.rs:88:21 | |
| 246 | --> $DIR/pinned-drop-check.rs:139:21 | |
| 122 | 247 | | |
| 123 | 248 | LL | fn pin_drop(&mut self) {} |
| 124 | 249 | | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Bar>`, found `&mut pin_drop_wrong_type::Bar` |
| ... | ... | @@ -132,14 +257,14 @@ LL + fn pin_drop(self: Pin<&mut pin_drop_wrong_type::Bar>) {} |
| 132 | 257 | | |
| 133 | 258 | |
| 134 | 259 | error: `Bar` must implement `pin_drop` |
| 135 | --> $DIR/pinned-drop-check.rs:103:9 | |
| 260 | --> $DIR/pinned-drop-check.rs:154:9 | |
| 136 | 261 | | |
| 137 | 262 | LL | fn drop(&mut self) { |
| 138 | 263 | | ^^^^^^^^^^^^^^^^^^ |
| 139 | 264 | | |
| 140 | 265 | = help: structurally pinned types must keep `Pin`'s safety contract |
| 141 | 266 | note: `Bar` is marked `#[pin_v2]` here |
| 142 | --> $DIR/pinned-drop-check.rs:94:5 | |
| 267 | --> $DIR/pinned-drop-check.rs:145:5 | |
| 143 | 268 | | |
| 144 | 269 | LL | #[pin_v2] |
| 145 | 270 | | ^^^^^^^^^ |
| ... | ... | @@ -154,30 +279,42 @@ LL - #[pin_v2] |
| 154 | 279 | | |
| 155 | 280 | |
| 156 | 281 | error[E0040]: explicit use of destructor method |
| 157 | --> $DIR/pinned-drop-check.rs:99:13 | |
| 282 | --> $DIR/pinned-drop-check.rs:150:13 | |
| 158 | 283 | | |
| 159 | 284 | LL | Drop::pin_drop(todo!()); |
| 160 | 285 | | ^^^^^^^^^^^^^^ explicit destructor calls not allowed |
| 161 | 286 | |
| 162 | 287 | error[E0040]: explicit use of destructor method |
| 163 | --> $DIR/pinned-drop-check.rs:105:13 | |
| 288 | --> $DIR/pinned-drop-check.rs:156:13 | |
| 164 | 289 | | |
| 165 | 290 | LL | Drop::pin_drop(todo!()); |
| 166 | 291 | | ^^^^^^^^^^^^^^ explicit destructor calls not allowed |
| 167 | 292 | |
| 168 | 293 | error[E0040]: explicit use of destructor method |
| 169 | --> $DIR/pinned-drop-check.rs:117:13 | |
| 294 | --> $DIR/pinned-drop-check.rs:168:13 | |
| 295 | | | |
| 296 | LL | Drop::drop(todo!()); | |
| 297 | | ^^^^^^^^^^ explicit destructor calls not allowed | |
| 298 | ||
| 299 | error[E0040]: explicit use of destructor method | |
| 300 | --> $DIR/pinned-drop-check.rs:173:13 | |
| 170 | 301 | | |
| 171 | 302 | LL | Drop::drop(todo!()); |
| 172 | 303 | | ^^^^^^^^^^ explicit destructor calls not allowed |
| 173 | 304 | |
| 174 | 305 | error[E0040]: explicit use of destructor method |
| 175 | --> $DIR/pinned-drop-check.rs:122:13 | |
| 306 | --> $DIR/pinned-drop-check.rs:183:13 | |
| 176 | 307 | | |
| 177 | 308 | LL | Drop::drop(todo!()); |
| 178 | 309 | | ^^^^^^^^^^ explicit destructor calls not allowed |
| 179 | 310 | |
| 180 | error: aborting due to 15 previous errors | |
| 311 | error[E0040]: explicit use of destructor method | |
| 312 | --> $DIR/pinned-drop-check.rs:184:13 | |
| 313 | | | |
| 314 | LL | Drop::pin_drop(todo!()); | |
| 315 | | ^^^^^^^^^^^^^^ explicit destructor calls not allowed | |
| 316 | ||
| 317 | error: aborting due to 25 previous errors | |
| 181 | 318 | |
| 182 | Some errors have detailed explanations: E0040, E0046, E0053. | |
| 319 | Some errors have detailed explanations: E0040, E0046, E0053, E0201. | |
| 183 | 320 | For more information about an error, try `rustc --explain E0040`. |
tests/ui/pin-ergonomics/pinned-drop-sugar-no-core.rs created+78| ... | ... | @@ -0,0 +1,78 @@ |
| 1 | //@ check-pass | |
| 2 | ||
| 3 | #![no_std] | |
| 4 | #![no_core] | |
| 5 | #![no_main] | |
| 6 | #![feature(no_core, pin_ergonomics, lang_items)] | |
| 7 | #![allow(incomplete_features)] | |
| 8 | ||
| 9 | #[lang = "pointee_sized"] | |
| 10 | trait PointeeSized {} | |
| 11 | ||
| 12 | #[lang = "meta_sized"] | |
| 13 | trait MetaSized: PointeeSized {} | |
| 14 | ||
| 15 | #[lang = "sized"] | |
| 16 | trait Sized: MetaSized {} | |
| 17 | ||
| 18 | #[lang = "copy"] | |
| 19 | trait Copy {} | |
| 20 | ||
| 21 | #[lang = "legacy_receiver"] | |
| 22 | trait LegacyReceiver: PointeeSized {} | |
| 23 | ||
| 24 | #[lang = "deref"] | |
| 25 | trait Deref: PointeeSized { | |
| 26 | #[lang = "deref_target"] | |
| 27 | type Target: PointeeSized; | |
| 28 | ||
| 29 | fn deref(&self) -> &Self::Target; | |
| 30 | } | |
| 31 | ||
| 32 | #[lang = "deref_mut"] | |
| 33 | trait DerefMut: Deref + PointeeSized { | |
| 34 | fn deref_mut(&mut self) -> &mut Self::Target; | |
| 35 | } | |
| 36 | ||
| 37 | #[lang = "pin"] | |
| 38 | struct Pin<T> { | |
| 39 | pointer: T, | |
| 40 | } | |
| 41 | ||
| 42 | impl<T: PointeeSized> LegacyReceiver for &T {} | |
| 43 | impl<T: PointeeSized> LegacyReceiver for &mut T {} | |
| 44 | impl<Ptr: LegacyReceiver> LegacyReceiver for Pin<Ptr> {} | |
| 45 | ||
| 46 | impl<Ptr: Deref> Deref for Pin<Ptr> { | |
| 47 | type Target = Ptr::Target; | |
| 48 | ||
| 49 | fn deref(&self) -> &Self::Target { | |
| 50 | &*self.pointer | |
| 51 | } | |
| 52 | } | |
| 53 | ||
| 54 | impl<Ptr: DerefMut> DerefMut for Pin<Ptr> { | |
| 55 | fn deref_mut(&mut self) -> &mut Self::Target { | |
| 56 | &mut *self.pointer | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | impl<T: PointeeSized> Deref for &mut T { | |
| 61 | type Target = T; | |
| 62 | ||
| 63 | fn deref(&self) -> &Self::Target { | |
| 64 | self | |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | struct LocalDrop; | |
| 69 | ||
| 70 | impl Drop for LocalDrop { | |
| 71 | fn drop(&pin mut self) {} | |
| 72 | } | |
| 73 | ||
| 74 | #[lang = "drop"] | |
| 75 | trait Drop { | |
| 76 | fn drop(&mut self) {} | |
| 77 | fn pin_drop(self: Pin<&mut Self>) {} | |
| 78 | } |
tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.rs created+62| ... | ... | @@ -0,0 +1,62 @@ |
| 1 | //@ edition:2024 | |
| 2 | ||
| 3 | #![feature(pin_ergonomics)] | |
| 4 | #![allow(incomplete_features)] | |
| 5 | ||
| 6 | use std::pin::Pin; | |
| 7 | ||
| 8 | struct S; | |
| 9 | ||
| 10 | trait NeedsPinDrop { | |
| 11 | fn pin_drop(self: Pin<&mut Self>); | |
| 12 | } | |
| 13 | ||
| 14 | impl NeedsPinDrop for S { | |
| 15 | //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046] | |
| 16 | fn drop(&pin mut self) {} | |
| 17 | //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait | |
| 18 | } | |
| 19 | ||
| 20 | trait HasDrop { | |
| 21 | fn drop(self: Pin<&mut Self>); | |
| 22 | } | |
| 23 | ||
| 24 | impl HasDrop for S { | |
| 25 | //~^ ERROR not all trait items implemented, missing: `drop` [E0046] | |
| 26 | fn drop(&pin mut self) {} | |
| 27 | //~^ ERROR method `drop` is not a member of trait `HasDrop` [E0407] | |
| 28 | } | |
| 29 | ||
| 30 | trait HasPinnedDropReceiver { | |
| 31 | fn drop(self: &pin mut Self); | |
| 32 | } | |
| 33 | ||
| 34 | impl HasPinnedDropReceiver for S { | |
| 35 | //~^ ERROR not all trait items implemented, missing: `drop` [E0046] | |
| 36 | fn drop(&pin mut self) {} | |
| 37 | //~^ ERROR method `drop` is not a member of trait `HasPinnedDropReceiver` [E0407] | |
| 38 | } | |
| 39 | ||
| 40 | struct Inherent; | |
| 41 | ||
| 42 | impl Inherent { | |
| 43 | fn drop(&pin mut self) {} | |
| 44 | } | |
| 45 | ||
| 46 | mod local_drop_trait { | |
| 47 | use std::pin::Pin; | |
| 48 | ||
| 49 | struct S; | |
| 50 | ||
| 51 | trait Drop { | |
| 52 | fn pin_drop(self: Pin<&mut Self>); | |
| 53 | } | |
| 54 | ||
| 55 | impl Drop for S { | |
| 56 | //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046] | |
| 57 | fn drop(&pin mut self) {} | |
| 58 | //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait | |
| 59 | } | |
| 60 | } | |
| 61 | ||
| 62 | fn main() {} |
tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.stderr created+70| ... | ... | @@ -0,0 +1,70 @@ |
| 1 | error[E0407]: method `drop` is not a member of trait `HasDrop` | |
| 2 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:26:5 | |
| 3 | | | |
| 4 | LL | fn drop(&pin mut self) {} | |
| 5 | | ^^^----^^^^^^^^^^^^^^^^^^ | |
| 6 | | | | | |
| 7 | | | help: there is an associated function with a similar name: `drop` | |
| 8 | | not a member of trait `HasDrop` | |
| 9 | ||
| 10 | error[E0407]: method `drop` is not a member of trait `HasPinnedDropReceiver` | |
| 11 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:36:5 | |
| 12 | | | |
| 13 | LL | fn drop(&pin mut self) {} | |
| 14 | | ^^^----^^^^^^^^^^^^^^^^^^ | |
| 15 | | | | | |
| 16 | | | help: there is an associated function with a similar name: `drop` | |
| 17 | | not a member of trait `HasPinnedDropReceiver` | |
| 18 | ||
| 19 | error: method `drop` with `&pin mut self` is only supported for the `Drop` trait | |
| 20 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:16:5 | |
| 21 | | | |
| 22 | LL | fn drop(&pin mut self) {} | |
| 23 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation | |
| 24 | ||
| 25 | error: method `drop` with `&pin mut self` is only supported for the `Drop` trait | |
| 26 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:57:9 | |
| 27 | | | |
| 28 | LL | fn drop(&pin mut self) {} | |
| 29 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation | |
| 30 | ||
| 31 | error[E0046]: not all trait items implemented, missing: `pin_drop` | |
| 32 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:14:1 | |
| 33 | | | |
| 34 | LL | fn pin_drop(self: Pin<&mut Self>); | |
| 35 | | ---------------------------------- `pin_drop` from trait | |
| 36 | ... | |
| 37 | LL | impl NeedsPinDrop for S { | |
| 38 | | ^^^^^^^^^^^^^^^^^^^^^^^ missing `pin_drop` in implementation | |
| 39 | ||
| 40 | error[E0046]: not all trait items implemented, missing: `drop` | |
| 41 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:24:1 | |
| 42 | | | |
| 43 | LL | fn drop(self: Pin<&mut Self>); | |
| 44 | | ------------------------------ `drop` from trait | |
| 45 | ... | |
| 46 | LL | impl HasDrop for S { | |
| 47 | | ^^^^^^^^^^^^^^^^^^ missing `drop` in implementation | |
| 48 | ||
| 49 | error[E0046]: not all trait items implemented, missing: `drop` | |
| 50 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:34:1 | |
| 51 | | | |
| 52 | LL | fn drop(self: &pin mut Self); | |
| 53 | | ----------------------------- `drop` from trait | |
| 54 | ... | |
| 55 | LL | impl HasPinnedDropReceiver for S { | |
| 56 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation | |
| 57 | ||
| 58 | error[E0046]: not all trait items implemented, missing: `pin_drop` | |
| 59 | --> $DIR/pinned-drop-sugar-not-other-traits.rs:55:5 | |
| 60 | | | |
| 61 | LL | fn pin_drop(self: Pin<&mut Self>); | |
| 62 | | ---------------------------------- `pin_drop` from trait | |
| 63 | ... | |
| 64 | LL | impl Drop for S { | |
| 65 | | ^^^^^^^^^^^^^^^ missing `pin_drop` in implementation | |
| 66 | ||
| 67 | error: aborting due to 8 previous errors | |
| 68 | ||
| 69 | Some errors have detailed explanations: E0046, E0407. | |
| 70 | For more information about an error, try `rustc --explain E0046`. |
tests/ui/pin-ergonomics/pinned-drop-sugar.rs created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //@ check-pass | |
| 2 | //@ edition:2024 | |
| 3 | ||
| 4 | #![feature(pin_ergonomics)] | |
| 5 | #![allow(incomplete_features)] | |
| 6 | ||
| 7 | struct Unpinned; | |
| 8 | ||
| 9 | #[pin_v2] | |
| 10 | struct Pinned; | |
| 11 | ||
| 12 | struct Qualified; | |
| 13 | struct CoreQualified; | |
| 14 | ||
| 15 | impl Drop for Unpinned { | |
| 16 | fn drop(&pin mut self) {} | |
| 17 | } | |
| 18 | ||
| 19 | impl Drop for Pinned { | |
| 20 | fn drop(&pin mut self) {} | |
| 21 | } | |
| 22 | ||
| 23 | impl std::ops::Drop for Qualified { | |
| 24 | fn drop(&pin mut self) {} | |
| 25 | } | |
| 26 | ||
| 27 | impl core::ops::Drop for CoreQualified { | |
| 28 | fn drop(&pin mut self) {} | |
| 29 | } | |
| 30 | ||
| 31 | fn main() {} |
tests/ui/suggestions/auxiliary/generics_other_crate.rs created+4| ... | ... | @@ -0,0 +1,4 @@ |
| 1 | //! This file is used to test suggestions for generics in other crates. | |
| 2 | ||
| 3 | pub struct External; | |
| 4 | pub struct ExternalGeneric<T>(T); |
tests/ui/suggestions/unconstrained-params.rs created+54| ... | ... | @@ -0,0 +1,54 @@ |
| 1 | //@ aux-build:generics_other_crate.rs | |
| 2 | ||
| 3 | extern crate generics_other_crate; | |
| 4 | use generics_other_crate::External; | |
| 5 | ||
| 6 | struct Local; | |
| 7 | struct Defaulted<T = u32>(T); | |
| 8 | ||
| 9 | // Case 1: Unused parameter -> suggests removing T | |
| 10 | impl<T> Local {} | |
| 11 | //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 12 | //~| HELP: remove the unused type parameter `T` | |
| 13 | ||
| 14 | // Case 2: T used in body but not in self type | |
| 15 | // -> suggests adding T to self type and struct definition | |
| 16 | impl<T> Local { | |
| 17 | //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 18 | //~| HELP: use the type parameter `T` in the `Local` type and use it in the type definition | |
| 19 | fn check() { | |
| 20 | let _: T; | |
| 21 | } | |
| 22 | } | |
| 23 | ||
| 24 | ||
| 25 | // Case 3: Struct has a generic parameter with a default | |
| 26 | // -> suggests adding T to the self type | |
| 27 | impl<T> Defaulted {} | |
| 28 | //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 29 | //~| HELP: either remove the unused type parameter `T` | |
| 30 | //~| HELP: or use it | |
| 31 | ||
| 32 | // Case 4: Generated from a macro | |
| 33 | macro_rules! make_impl { | |
| 34 | ($t:ident) => { | |
| 35 | impl<$t> Local {} | |
| 36 | //~^ HELP: remove the unused type parameter `U` | |
| 37 | } | |
| 38 | } | |
| 39 | make_impl!(U); | |
| 40 | //~^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates | |
| 41 | ||
| 42 | // Case 5: Type defined in another crate | |
| 43 | impl<T> External { | |
| 44 | //~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 45 | //~| ERROR: cannot define inherent `impl` for a type outside of the crate where the type is defined [E0116] | |
| 46 | //~| HELP: use the type parameter `T` in the `External` type and use it in the type definition | |
| 47 | //~| HELP: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it | |
| 48 | fn check() { | |
| 49 | let _: T; | |
| 50 | } | |
| 51 | } | |
| 52 | ||
| 53 | ||
| 54 | fn main() {} |
tests/ui/suggestions/unconstrained-params.stderr created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 2 | --> $DIR/unconstrained-params.rs:10:6 | |
| 3 | | | |
| 4 | LL | impl<T> Local {} | |
| 5 | | -^- | |
| 6 | | || | |
| 7 | | |unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `T` | |
| 9 | ||
| 10 | error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 11 | --> $DIR/unconstrained-params.rs:16:6 | |
| 12 | | | |
| 13 | LL | impl<T> Local { | |
| 14 | | ^ unconstrained type parameter | |
| 15 | | | |
| 16 | help: use the type parameter `T` in the `Local` type and use it in the type definition | |
| 17 | | | |
| 18 | LL ~ struct Local<T>; | |
| 19 | LL | struct Defaulted<T = u32>(T); | |
| 20 | ... | |
| 21 | LL | // -> suggests adding T to self type and struct definition | |
| 22 | LL ~ impl<T> Local<T> { | |
| 23 | | | |
| 24 | ||
| 25 | error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 26 | --> $DIR/unconstrained-params.rs:27:6 | |
| 27 | | | |
| 28 | LL | impl<T> Defaulted {} | |
| 29 | | ^ unconstrained type parameter | |
| 30 | | | |
| 31 | help: either remove the unused type parameter `T` | |
| 32 | | | |
| 33 | LL - impl<T> Defaulted {} | |
| 34 | LL + impl Defaulted {} | |
| 35 | | | |
| 36 | help: or use it | |
| 37 | | | |
| 38 | LL | impl<T> Defaulted<T> {} | |
| 39 | | +++ | |
| 40 | ||
| 41 | error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates | |
| 42 | --> $DIR/unconstrained-params.rs:39:12 | |
| 43 | | | |
| 44 | LL | impl<$t> Local {} | |
| 45 | | ---- help: remove the unused type parameter `U` | |
| 46 | ... | |
| 47 | LL | make_impl!(U); | |
| 48 | | ^ unconstrained type parameter | |
| 49 | ||
| 50 | error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates | |
| 51 | --> $DIR/unconstrained-params.rs:43:6 | |
| 52 | | | |
| 53 | LL | impl<T> External { | |
| 54 | | ^ unconstrained type parameter | |
| 55 | ||
| 56 | error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined | |
| 57 | --> $DIR/unconstrained-params.rs:43:1 | |
| 58 | | | |
| 59 | LL | impl<T> External { | |
| 60 | | ^^^^^^^^^^^^^^^^ impl for type defined outside of crate | |
| 61 | | | |
| 62 | = help: consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it | |
| 63 | = note: for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules> | |
| 64 | ||
| 65 | error: aborting due to 6 previous errors | |
| 66 | ||
| 67 | Some errors have detailed explanations: E0116, E0207. | |
| 68 | For more information about an error, try `rustc --explain E0116`. |
tests/ui/traits/associated_type_bound/generic-const-args-default.rs+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | |
| 4 | 4 | #![feature(min_generic_const_args)] |
| 5 | 5 | |
| 6 | trait Bar<const N: bool = false> {} | |
| 6 | trait Bar<const N: usize = const { 1 + 1 }> {} | |
| 7 | 7 | |
| 8 | 8 | trait Foo { |
| 9 | 9 | type AssocB: Bar; |
tests/ui/traits/error-reporting/leaking-vars-in-cause-code-2.stderr+4-1| ... | ... | @@ -2,7 +2,10 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/leaking-vars-in-cause-code-2.rs:19:9 |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T, U> Trait<()> for B<T> |
| 5 | | ^ unconstrained type parameter | |
| 5 | | --^ | |
| 6 | | | | | |
| 7 | | | unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `U` | |
| 6 | 9 | |
| 7 | 10 | error[E0277]: the trait bound `(): IncompleteGuidance` is not satisfied |
| 8 | 11 | --> $DIR/leaking-vars-in-cause-code-2.rs:29:19 |
tests/ui/traits/normalize/unconstrained-projection-normalization-2.current.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T: ?Sized> Every for Thing { |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `Thing` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Thing<T>; | |
| 10 | LL | | |
| 11 | ... | |
| 12 | LL | } | |
| 13 | LL ~ impl<T: ?Sized> Every for Thing<T> { | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error[E0277]: the size for values of type `T` cannot be known at compilation time |
| 8 | 17 | --> $DIR/unconstrained-projection-normalization-2.rs:16:18 |
tests/ui/traits/normalize/unconstrained-projection-normalization-2.next.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T: ?Sized> Every for Thing { |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `Thing` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Thing<T>; | |
| 10 | LL | | |
| 11 | ... | |
| 12 | LL | } | |
| 13 | LL ~ impl<T: ?Sized> Every for Thing<T> { | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error[E0277]: the size for values of type `T` cannot be known at compilation time |
| 8 | 17 | --> $DIR/unconstrained-projection-normalization-2.rs:16:18 |
tests/ui/traits/normalize/unconstrained-projection-normalization.current.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T: ?Sized> Every for Thing { |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `Thing` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Thing<T>; | |
| 10 | LL | | |
| 11 | ... | |
| 12 | LL | } | |
| 13 | LL ~ impl<T: ?Sized> Every for Thing<T> { | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error[E0277]: the size for values of type `T` cannot be known at compilation time |
| 8 | 17 | --> $DIR/unconstrained-projection-normalization.rs:15:18 |
tests/ui/traits/normalize/unconstrained-projection-normalization.next.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T: ?Sized> Every for Thing { |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `Thing` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Thing<T>; | |
| 10 | LL | | |
| 11 | ... | |
| 12 | LL | } | |
| 13 | LL ~ impl<T: ?Sized> Every for Thing<T> { | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error[E0277]: the size for values of type `T` cannot be known at compilation time |
| 8 | 17 | --> $DIR/unconstrained-projection-normalization.rs:15:18 |
tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr+9| ... | ... | @@ -3,6 +3,15 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> { |
| 5 | 5 | | ^ unconstrained type parameter |
| 6 | | | |
| 7 | help: use the type parameter `T` in the `Scope` type and use it in the type definition | |
| 8 | | | |
| 9 | LL ~ struct Scope<T, T>(Phantom2<DummyT<T>>); | |
| 10 | LL | | |
| 11 | ... | |
| 12 | LL | | |
| 13 | LL ~ impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U, T> { | |
| 14 | | | |
| 6 | 15 | |
| 7 | 16 | error: item does not constrain `DummyT::{opaque#0}` |
| 8 | 17 | --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:30:8 |
tests/ui/type-alias-impl-trait/issue-74244.stderr+4-1| ... | ... | @@ -2,7 +2,10 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self |
| 2 | 2 | --> $DIR/issue-74244.rs:9:6 |
| 3 | 3 | | |
| 4 | 4 | LL | impl<T> Allocator for DefaultAllocator { |
| 5 | | ^ unconstrained type parameter | |
| 5 | | -^- | |
| 6 | | || | |
| 7 | | |unconstrained type parameter | |
| 8 | | help: remove the unused type parameter `T` | |
| 6 | 9 | |
| 7 | 10 | error: aborting due to 1 previous error |
| 8 | 11 |