| author | bors <bors@rust-lang.org> 2026-05-05 07:17:39 UTC |
| committer | bors <bors@rust-lang.org> 2026-05-05 07:17:39 UTC |
| log | 4feb7221f4d445120a5061b16ce7222adbfdf6f6 |
| tree | 1fb71b8922fb6c1cf4939199997fb707c7a20262 |
| parent | 83adf7e080d0fe4f0970c00eac2976a767dbd042 |
| parent | ba38fa014737aed9ec416f9a10432d64da7e1524 |
Rollup of 16 pull requests
Successful merges:
- rust-lang/rust#155848 ([doc]: Revert `core::io::ErrorKind` doc changes)
- rust-lang/rust#155855 (Remove unnecessary `get_unchecked`)
- rust-lang/rust#155543 (docs(unstable-book): Document const generics features)
- rust-lang/rust#155962 (`rustc`: `target_features`: allow for `cfg`-only stable `target_features`)
- rust-lang/rust#156043 (c-variadic: gate `va_arg` on `c_variadic_experimental_arch`)
- rust-lang/rust#156082 (Move tests associated types)
- rust-lang/rust#156087 (Improve `&pin` reference-pattern suggestions)
- rust-lang/rust#156092 (Clean up `TyCtxt::needs_crate_hash` usage and rename it to `needs_hir_hash`.)
- rust-lang/rust#156103 (Fix E0040 suggestion for explicit `Drop::drop` UFCS calls)
- rust-lang/rust#156104 (Relax `T: Sized` bound on `try_as_dyn` / `try_as_dyn_mut`)
- rust-lang/rust#156122 (Add a `doc_cfg` regression test to ensure foreign types impls are working as expected)
- rust-lang/rust#156128 (.mailmap: prefer matching just based on commit emails)
- rust-lang/rust#156135 (Remove most uses of def_id_to_node_id)
- rust-lang/rust#156152 (Update books)
- rust-lang/rust#156154 (tests: mark import UI tests as check-pass)
- rust-lang/rust#156162 (Update `browser-ui-test` version to `0.23.5`)110 files changed, 1496 insertions(+), 686 deletions(-)
.mailmap+3-5| ... | ... | @@ -259,11 +259,9 @@ Gregor Peach <gregorpeach@gmail.com> |
| 259 | 259 | Grzegorz Bartoszek <grzegorz.bartoszek@thaumatec.com> |
| 260 | 260 | Guanqun Lu <guanqun.lu@gmail.com> |
| 261 | 261 | Guillaume Gomez <contact@guillaume-gomez.fr> |
| 262 | Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <guillaume1.gomez@gmail.com> | |
| 263 | Guillaume Gomez <contact@guillaume-gomez.fr> ggomez <guillaume1.gomez@gmail.com> | |
| 264 | Guillaume Gomez <contact@guillaume-gomez.fr> ggomez <ggomez@ggo.ifr.lan> | |
| 265 | Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <ggomez@ggo.ifr.lan> | |
| 266 | Guillaume Gomez <contact@guillaume-gomez.fr> Guillaume Gomez <guillaume.gomez@huawei.com> | |
| 262 | Guillaume Gomez <contact@guillaume-gomez.fr> <guillaume1.gomez@gmail.com> | |
| 263 | Guillaume Gomez <contact@guillaume-gomez.fr> <ggomez@ggo.ifr.lan> | |
| 264 | Guillaume Gomez <contact@guillaume-gomez.fr> <guillaume.gomez@huawei.com> | |
| 267 | 265 | gnzlbg <gonzalobg88@gmail.com> <gnzlbg@users.noreply.github.com> |
| 268 | 266 | hamidreza kalbasi <hamidrezakalbasi@protonmail.com> |
| 269 | 267 | Hanna Kruppe <hanna.kruppe@gmail.com> <robin.kruppe@gmail.com> |
compiler/rustc_ast_lowering/src/lib.rs+1-1| ... | ... | @@ -562,7 +562,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> { |
| 562 | 562 | |
| 563 | 563 | // Don't hash unless necessary, because it's expensive. |
| 564 | 564 | let opt_hir_hash = |
| 565 | if tcx.needs_crate_hash() { Some(compute_hir_hash(tcx, &owners)) } else { None }; | |
| 565 | if tcx.needs_hir_hash() { Some(compute_hir_hash(tcx, &owners)) } else { None }; | |
| 566 | 566 | |
| 567 | 567 | let delayed_resolver = Steal::new((resolver, krate)); |
| 568 | 568 | mid_hir::Crate::new(owners, delayed_ids, delayed_resolver, opt_hir_hash) |
compiler/rustc_codegen_llvm/src/intrinsic.rs+13-2| ... | ... | @@ -3,8 +3,8 @@ use std::ffi::c_uint; |
| 3 | 3 | use std::{assert_matches, iter, ptr}; |
| 4 | 4 | |
| 5 | 5 | use rustc_abi::{ |
| 6 | AddressSpace, Align, BackendRepr, Float, HasDataLayout, Integer, NumScalableVectors, Primitive, | |
| 7 | Size, WrappingRange, | |
| 6 | AddressSpace, Align, BackendRepr, CVariadicStatus, Float, HasDataLayout, Integer, | |
| 7 | NumScalableVectors, Primitive, Size, WrappingRange, | |
| 8 | 8 | }; |
| 9 | 9 | use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh}; |
| 10 | 10 | use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; |
| ... | ... | @@ -23,6 +23,7 @@ use rustc_middle::ty::{ |
| 23 | 23 | }; |
| 24 | 24 | use rustc_middle::{bug, span_bug}; |
| 25 | 25 | use rustc_session::config::CrateType; |
| 26 | use rustc_session::errors::feature_err; | |
| 26 | 27 | use rustc_session::lint::builtin::DEPRECATED_LLVM_INTRINSIC; |
| 27 | 28 | use rustc_span::{Span, Symbol, sym}; |
| 28 | 29 | use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate}; |
| ... | ... | @@ -288,6 +289,16 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { |
| 288 | 289 | } |
| 289 | 290 | sym::breakpoint => self.call_intrinsic("llvm.debugtrap", &[], &[]), |
| 290 | 291 | sym::va_arg => { |
| 292 | let target = &self.cx.tcx.sess.target; | |
| 293 | let stability = target.supports_c_variadic_definitions(); | |
| 294 | if let CVariadicStatus::Unstable { feature } = stability | |
| 295 | && !self.tcx.features().enabled(feature) | |
| 296 | { | |
| 297 | let msg = | |
| 298 | format!("C-variadic function definitions on this target are unstable"); | |
| 299 | feature_err(&*self.sess(), feature, span, msg).emit(); | |
| 300 | } | |
| 301 | ||
| 291 | 302 | let BackendRepr::Scalar(scalar) = result.layout.backend_repr else { |
| 292 | 303 | bug!("the va_arg intrinsic does not support non-scalar types") |
| 293 | 304 | }; |
compiler/rustc_codegen_ssa/src/errors.rs+2-1| ... | ... | @@ -1212,9 +1212,10 @@ pub(crate) struct UnknownCTargetFeature<'a> { |
| 1212 | 1212 | |
| 1213 | 1213 | #[derive(Diagnostic)] |
| 1214 | 1214 | #[diag("unstable feature specified for `-Ctarget-feature`: `{$feature}`")] |
| 1215 | #[note("this feature is not stably supported; its behavior can change in the future")] | |
| 1215 | #[note("{$note}; its behavior can change in the future")] | |
| 1216 | 1216 | pub(crate) struct UnstableCTargetFeature<'a> { |
| 1217 | 1217 | pub feature: &'a str, |
| 1218 | pub note: &'a str, | |
| 1218 | 1219 | } |
| 1219 | 1220 | |
| 1220 | 1221 | #[derive(Diagnostic)] |
compiler/rustc_codegen_ssa/src/target_features.rs+19-12| ... | ... | @@ -62,16 +62,15 @@ pub(crate) fn from_target_feature_attr( |
| 62 | 62 | feature: feature_str, |
| 63 | 63 | reason, |
| 64 | 64 | }); |
| 65 | } else if let Some(nightly_feature) = stability.requires_nightly() | |
| 65 | } else if let Some(nightly_feature) = stability.requires_nightly(/* in_cfg */ false) | |
| 66 | 66 | && !rust_features.enabled(nightly_feature) |
| 67 | 67 | { |
| 68 | feature_err( | |
| 69 | &tcx.sess, | |
| 70 | nightly_feature, | |
| 71 | feature_span, | |
| 72 | format!("the target feature `{feature}` is currently unstable"), | |
| 73 | ) | |
| 74 | .emit(); | |
| 68 | let explain = if stability.is_cfg_stable_toggle_unstable() { | |
| 69 | format!("the target feature `{feature}` is allowed in cfg but unstable otherwise") | |
| 70 | } else { | |
| 71 | format!("the target feature `{feature}` is currently unstable") | |
| 72 | }; | |
| 73 | feature_err(&tcx.sess, nightly_feature, feature_span, explain).emit(); | |
| 75 | 74 | } else { |
| 76 | 75 | // Add this and the implied features. |
| 77 | 76 | for &name in tcx.implied_target_features(feature) { |
| ... | ... | @@ -315,12 +314,19 @@ pub fn cfg_target_feature<'a, const N: usize>( |
| 315 | 314 | enabled: if enable { "enabled" } else { "disabled" }, |
| 316 | 315 | reason, |
| 317 | 316 | }); |
| 318 | } else if stability.requires_nightly().is_some() { | |
| 317 | } else if stability.requires_nightly(/* in_cfg */ false).is_some() { | |
| 319 | 318 | // An unstable feature. Warn about using it. It makes little sense |
| 320 | 319 | // to hard-error here since we just warn about fully unknown |
| 321 | 320 | // features above. |
| 322 | sess.dcx() | |
| 323 | .emit_warn(errors::UnstableCTargetFeature { feature: base_feature }); | |
| 321 | let note = if stability.is_cfg_stable_toggle_unstable() { | |
| 322 | "this feature is allowed in cfg but unstable otherwise" | |
| 323 | } else { | |
| 324 | "this feature is not stably supported" | |
| 325 | }; | |
| 326 | sess.dcx().emit_warn(errors::UnstableCTargetFeature { | |
| 327 | feature: base_feature, | |
| 328 | note, | |
| 329 | }); | |
| 324 | 330 | } |
| 325 | 331 | } |
| 326 | 332 | } |
| ... | ... | @@ -346,7 +352,8 @@ pub fn cfg_target_feature<'a, const N: usize>( |
| 346 | 352 | // "forbidden" features. |
| 347 | 353 | if allow_unstable |
| 348 | 354 | || (gate.in_cfg() |
| 349 | && (sess.is_nightly_build() || gate.requires_nightly().is_none())) | |
| 355 | && (sess.is_nightly_build() | |
| 356 | || gate.requires_nightly(/* in_cfg */ true).is_none())) | |
| 350 | 357 | { |
| 351 | 358 | Some(Symbol::intern(feature)) |
| 352 | 359 | } else { |
compiler/rustc_feature/src/unstable.rs+5-3| ... | ... | @@ -563,8 +563,9 @@ declare_features! ( |
| 563 | 563 | /// Allows defining gen blocks and `gen fn`. |
| 564 | 564 | (unstable, gen_blocks, "1.75.0", Some(117078)), |
| 565 | 565 | /// Allows using generics in more complex const expressions, based on definitional equality. |
| 566 | (unstable, generic_const_args, "1.95.0", Some(151972)), | |
| 567 | /// Allows non-trivial generic constants which have to have wfness manually propagated to callers | |
| 566 | (incomplete, generic_const_args, "1.95.0", Some(151972)), | |
| 567 | /// Allows non-trivial generic constants which have to be shown to successfully evaluate | |
| 568 | /// to a value by being part of an item signature. | |
| 568 | 569 | (incomplete, generic_const_exprs, "1.56.0", Some(76560)), |
| 569 | 570 | /// Allows generic parameters and where-clauses on free & associated const items. |
| 570 | 571 | (incomplete, generic_const_items, "1.73.0", Some(113521)), |
| ... | ... | @@ -626,7 +627,8 @@ declare_features! ( |
| 626 | 627 | /// Allows additional const parameter types, such as [u8; 10] or user defined types. |
| 627 | 628 | /// User defined types must not have fields more private than the type itself. |
| 628 | 629 | (unstable, min_adt_const_params, "1.96.0", Some(154042)), |
| 629 | /// Enables the generic const args MVP (only bare paths, not arbitrary computation). | |
| 630 | /// Enables the generic const args MVP (paths to type const items and constructors | |
| 631 | /// for ADTs and primitives). | |
| 630 | 632 | (incomplete, min_generic_const_args, "1.84.0", Some(132980)), |
| 631 | 633 | /// A minimal, sound subset of specialization intended to be used by the |
| 632 | 634 | /// standard library until the soundness issues with specialization |
compiler/rustc_hir_typeck/src/callee.rs+1-1| ... | ... | @@ -42,7 +42,7 @@ pub(crate) fn check_legal_trait_for_method_call( |
| 42 | 42 | if tcx.is_lang_item(trait_id, LangItem::Drop) { |
| 43 | 43 | let sugg = if let Some(receiver) = receiver.filter(|s| !s.is_empty()) { |
| 44 | 44 | errors::ExplicitDestructorCallSugg::Snippet { |
| 45 | lo: expr_span.shrink_to_lo(), | |
| 45 | lo: expr_span.shrink_to_lo().to(receiver.shrink_to_lo()), | |
| 46 | 46 | hi: receiver.shrink_to_hi().to(expr_span.shrink_to_hi()), |
| 47 | 47 | } |
| 48 | 48 | } else { |
compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs+15-1| ... | ... | @@ -1007,10 +1007,24 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1007 | 1007 | debug!(?def_id, ?container, ?container_id); |
| 1008 | 1008 | match container { |
| 1009 | 1009 | ty::AssocContainer::Trait => { |
| 1010 | let arg_span = if let hir::Node::Expr(call_expr) = | |
| 1011 | self.tcx.parent_hir_node(hir_id) | |
| 1012 | && let hir::ExprKind::Call(_, args) = call_expr.kind | |
| 1013 | && let Some(first_arg) = args.first() | |
| 1014 | { | |
| 1015 | let mut arg = first_arg; | |
| 1016 | while let hir::ExprKind::AddrOf(_, _, inner) = arg.kind { | |
| 1017 | arg = inner; | |
| 1018 | } | |
| 1019 | Some(arg.span) | |
| 1020 | } else { | |
| 1021 | None | |
| 1022 | }; | |
| 1023 | ||
| 1010 | 1024 | if let Err(e) = callee::check_legal_trait_for_method_call( |
| 1011 | 1025 | tcx, |
| 1012 | 1026 | path_span, |
| 1013 | None, | |
| 1027 | arg_span, | |
| 1014 | 1028 | span, |
| 1015 | 1029 | container_id, |
| 1016 | 1030 | self.body_id.to_def_id(), |
compiler/rustc_hir_typeck/src/pat.rs+9-2| ... | ... | @@ -1352,7 +1352,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | /// Precondition: pat is a `Ref(_)` pattern |
| 1355 | // FIXME(pin_ergonomics): add suggestions for `&pin mut` or `&pin const` patterns | |
| 1356 | 1355 | fn borrow_pat_suggestion(&self, err: &mut Diag<'_>, pat: &Pat<'_>) { |
| 1357 | 1356 | let tcx = self.tcx; |
| 1358 | 1357 | if let PatKind::Ref(inner, pinned, mutbl) = pat.kind |
| ... | ... | @@ -1407,6 +1406,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1407 | 1406 | }; |
| 1408 | 1407 | |
| 1409 | 1408 | match binding_parent { |
| 1409 | hir::Node::Param(hir::Param { ty_span, pat, .. }) | |
| 1410 | if pat.span != *ty_span | |
| 1411 | && pinned.is_pinned() | |
| 1412 | && !tcx.features().pin_ergonomics() => | |
| 1413 | { | |
| 1414 | // FIXME(pin_ergonomics): Once `pin_ergonomics` is stabilized, remove this | |
| 1415 | // gate and allow the pinned reference type-position suggestion unconditionally. | |
| 1416 | } | |
| 1410 | 1417 | // Check that there is explicit type (ie this is not a closure param with inferred type) |
| 1411 | 1418 | // so we don't suggest moving something to the type that does not exist |
| 1412 | 1419 | hir::Node::Param(hir::Param { ty_span, pat, .. }) if pat.span != *ty_span => { |
| ... | ... | @@ -1414,7 +1421,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1414 | 1421 | format!("to take parameter `{binding}` by reference, move `&{pin_and_mut}` to the type"), |
| 1415 | 1422 | vec![ |
| 1416 | 1423 | (pat.span.until(inner.span), "".to_owned()), |
| 1417 | (ty_span.shrink_to_lo(), mutbl.ref_prefix_str().to_owned()), | |
| 1424 | (ty_span.shrink_to_lo(), format!("&{}", pinned.prefix_str(mutbl))), | |
| 1418 | 1425 | ], |
| 1419 | 1426 | Applicability::MachineApplicable |
| 1420 | 1427 | ); |
compiler/rustc_interface/src/queries.rs+1-1| ... | ... | @@ -36,7 +36,7 @@ impl Linker { |
| 36 | 36 | Linker { |
| 37 | 37 | dep_graph: tcx.dep_graph.clone(), |
| 38 | 38 | output_filenames: Arc::clone(tcx.output_filenames(())), |
| 39 | crate_hash: if tcx.needs_crate_hash() { | |
| 39 | crate_hash: if tcx.sess.opts.incremental.is_some() { | |
| 40 | 40 | Some(tcx.crate_hash(LOCAL_CRATE)) |
| 41 | 41 | } else { |
| 42 | 42 | None |
compiler/rustc_middle/src/hir/mod.rs+1-1| ... | ... | @@ -237,7 +237,7 @@ impl<'tcx> TyCtxt<'tcx> { |
| 237 | 237 | attrs: &SortedMap<ItemLocalId, &[Attribute]>, |
| 238 | 238 | define_opaque: Option<&[(Span, LocalDefId)]>, |
| 239 | 239 | ) -> Hashes { |
| 240 | if !self.needs_crate_hash() { | |
| 240 | if !self.needs_hir_hash() { | |
| 241 | 241 | return Hashes { opt_hash_including_bodies: None, attrs_hash: None }; |
| 242 | 242 | } |
| 243 | 243 |
compiler/rustc_middle/src/ty/context.rs+3-3| ... | ... | @@ -1127,12 +1127,12 @@ impl<'tcx> TyCtxt<'tcx> { |
| 1127 | 1127 | }) |
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | pub fn needs_crate_hash(self) -> bool { | |
| 1131 | // Why is the crate hash needed for these configurations? | |
| 1130 | pub fn needs_hir_hash(self) -> bool { | |
| 1131 | // Why is the hir hash needed for these configurations? | |
| 1132 | 1132 | // - debug_assertions: for the "fingerprint the result" check in |
| 1133 | 1133 | // `rustc_query_impl::execution::execute_job`. |
| 1134 | 1134 | // - incremental: for query lookups. |
| 1135 | // - needs_metadata: for putting into crate metadata. | |
| 1135 | // - needs_metadata: it is included in the crate metadata through the crate_hash query | |
| 1136 | 1136 | // - instrument_coverage: for putting into coverage data (see |
| 1137 | 1137 | // `hash_mir_source`). |
| 1138 | 1138 | // - metrics_dir: metrics use the strict version hash in the filenames |
compiler/rustc_resolve/src/build_reduced_graph.rs+12-6| ... | ... | @@ -9,8 +9,9 @@ use std::sync::Arc; |
| 9 | 9 | |
| 10 | 10 | use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind}; |
| 11 | 11 | use rustc_ast::{ |
| 12 | self as ast, AssocItem, AssocItemKind, Block, ConstItem, Delegation, Fn, ForeignItem, | |
| 13 | ForeignItemKind, Inline, Item, ItemKind, NodeId, StaticItem, StmtKind, TraitAlias, TyAlias, | |
| 12 | self as ast, AssocItem, AssocItemKind, Block, ConstItem, DUMMY_NODE_ID, Delegation, Fn, | |
| 13 | ForeignItem, ForeignItemKind, Inline, Item, ItemKind, NodeId, StaticItem, StmtKind, TraitAlias, | |
| 14 | TyAlias, | |
| 14 | 15 | }; |
| 15 | 16 | use rustc_attr_parsing::AttributeParser; |
| 16 | 17 | use rustc_expand::base::ResolverExpand; |
| ... | ... | @@ -168,7 +169,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 168 | 169 | let expn_id = self.cstore().expn_that_defined_untracked(self.tcx, def_id); |
| 169 | 170 | let module = self.new_extern_module( |
| 170 | 171 | parent, |
| 171 | ModuleKind::Def(def_kind, def_id, Some(self.tcx.item_name(def_id))), | |
| 172 | ModuleKind::Def( | |
| 173 | def_kind, | |
| 174 | def_id, | |
| 175 | DUMMY_NODE_ID, | |
| 176 | Some(self.tcx.item_name(def_id)), | |
| 177 | ), | |
| 172 | 178 | expn_id, |
| 173 | 179 | self.def_span(def_id), |
| 174 | 180 | // FIXME: Account for `#[no_implicit_prelude]` attributes. |
| ... | ... | @@ -251,7 +257,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 251 | 257 | // Any inherited visibility resolved directly inside an enum or trait |
| 252 | 258 | // (i.e. variants, fields, and trait items) inherits from the visibility |
| 253 | 259 | // of the enum or trait. |
| 254 | ModuleKind::Def(DefKind::Enum | DefKind::Trait, def_id, _) => { | |
| 260 | ModuleKind::Def(DefKind::Enum | DefKind::Trait, def_id, _, _) => { | |
| 255 | 261 | self.tcx.visibility(def_id).expect_local() |
| 256 | 262 | } |
| 257 | 263 | // Otherwise, the visibility is restricted to the nearest parent `mod` item. |
| ... | ... | @@ -848,7 +854,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { |
| 848 | 854 | } |
| 849 | 855 | let module = self.r.new_local_module( |
| 850 | 856 | Some(parent), |
| 851 | ModuleKind::Def(def_kind, def_id, Some(ident.name)), | |
| 857 | ModuleKind::Def(def_kind, def_id, item.id, Some(ident.name)), | |
| 852 | 858 | expansion.to_expn_id(), |
| 853 | 859 | item.span, |
| 854 | 860 | parent.no_implicit_prelude |
| ... | ... | @@ -882,7 +888,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> { |
| 882 | 888 | |
| 883 | 889 | let module = self.r.new_local_module( |
| 884 | 890 | Some(parent), |
| 885 | ModuleKind::Def(def_kind, def_id, Some(ident.name)), | |
| 891 | ModuleKind::Def(def_kind, def_id, item.id, Some(ident.name)), | |
| 886 | 892 | expansion.to_expn_id(), |
| 887 | 893 | item.span, |
| 888 | 894 | parent.no_implicit_prelude, |
compiler/rustc_resolve/src/diagnostics.rs+22-21| ... | ... | @@ -5,7 +5,8 @@ use std::ops::ControlFlow; |
| 5 | 5 | use itertools::Itertools as _; |
| 6 | 6 | use rustc_ast::visit::{self, Visitor}; |
| 7 | 7 | use rustc_ast::{ |
| 8 | self as ast, CRATE_NODE_ID, Crate, ItemKind, ModKind, NodeId, Path, join_path_idents, | |
| 8 | self as ast, CRATE_NODE_ID, Crate, DUMMY_NODE_ID, ItemKind, ModKind, NodeId, Path, | |
| 9 | join_path_idents, | |
| 9 | 10 | }; |
| 10 | 11 | use rustc_ast_pretty::pprust; |
| 11 | 12 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| ... | ... | @@ -192,11 +193,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 192 | 193 | } |
| 193 | 194 | |
| 194 | 195 | fn report_with_use_injections(&mut self, krate: &Crate) { |
| 195 | for UseError { mut err, candidates, def_id, instead, suggestion, path, is_call } in | |
| 196 | for UseError { mut err, candidates, node_id, instead, suggestion, path, is_call } in | |
| 196 | 197 | mem::take(&mut self.use_injections) |
| 197 | 198 | { |
| 198 | let (span, found_use) = if let Some(def_id) = def_id.as_local() { | |
| 199 | UsePlacementFinder::check(krate, self.def_id_to_node_id(def_id)) | |
| 199 | let (span, found_use) = if node_id != DUMMY_NODE_ID { | |
| 200 | UsePlacementFinder::check(krate, node_id) | |
| 200 | 201 | } else { |
| 201 | 202 | (None, FoundUse::No) |
| 202 | 203 | }; |
| ... | ... | @@ -242,7 +243,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 242 | 243 | let container = match old_binding.parent_module.unwrap().kind { |
| 243 | 244 | // Avoid using TyCtxt::def_kind_descr in the resolver, because it |
| 244 | 245 | // indirectly *calls* the resolver, and would cause a query cycle. |
| 245 | ModuleKind::Def(kind, def_id, _) => kind.descr(def_id), | |
| 246 | ModuleKind::Def(kind, def_id, _, _) => kind.descr(def_id), | |
| 246 | 247 | ModuleKind::Block => "block", |
| 247 | 248 | }; |
| 248 | 249 | |
| ... | ... | @@ -1705,9 +1706,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1705 | 1706 | |
| 1706 | 1707 | let import_suggestions = |
| 1707 | 1708 | self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected); |
| 1708 | let (span, found_use) = match parent_scope.module.nearest_parent_mod().as_local() { | |
| 1709 | Some(def_id) => UsePlacementFinder::check(krate, self.def_id_to_node_id(def_id)), | |
| 1710 | None => (None, FoundUse::No), | |
| 1709 | let (span, found_use) = match parent_scope.module.nearest_parent_mod_node_id() { | |
| 1710 | DUMMY_NODE_ID => (None, FoundUse::No), | |
| 1711 | node_id => UsePlacementFinder::check(krate, node_id), | |
| 1711 | 1712 | }; |
| 1712 | 1713 | show_candidates( |
| 1713 | 1714 | self.tcx, |
| ... | ... | @@ -1764,7 +1765,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1764 | 1765 | } |
| 1765 | 1766 | |
| 1766 | 1767 | if ident.name == kw::Default |
| 1767 | && let ModuleKind::Def(DefKind::Enum, def_id, _) = parent_scope.module.kind | |
| 1768 | && let ModuleKind::Def(DefKind::Enum, def_id, _, _) = parent_scope.module.kind | |
| 1768 | 1769 | { |
| 1769 | 1770 | let span = self.def_span(def_id); |
| 1770 | 1771 | let source_map = self.tcx.sess.source_map(); |
| ... | ... | @@ -1892,19 +1893,19 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1892 | 1893 | missing a `derive` attribute", |
| 1893 | 1894 | ident.name, |
| 1894 | 1895 | ); |
| 1895 | let sugg_span = if let ModuleKind::Def(DefKind::Enum, id, _) = parent_scope.module.kind | |
| 1896 | { | |
| 1897 | let span = self.def_span(id); | |
| 1898 | if span.from_expansion() { | |
| 1899 | None | |
| 1896 | let sugg_span = | |
| 1897 | if let ModuleKind::Def(DefKind::Enum, id, _, _) = parent_scope.module.kind { | |
| 1898 | let span = self.def_span(id); | |
| 1899 | if span.from_expansion() { | |
| 1900 | None | |
| 1901 | } else { | |
| 1902 | // For enum variants sugg_span is empty but we can get the enum's Span. | |
| 1903 | Some(span.shrink_to_lo()) | |
| 1904 | } | |
| 1900 | 1905 | } else { |
| 1901 | // For enum variants sugg_span is empty but we can get the enum's Span. | |
| 1902 | Some(span.shrink_to_lo()) | |
| 1903 | } | |
| 1904 | } else { | |
| 1905 | // For items this `Span` will be populated, everything else it'll be None. | |
| 1906 | sugg_span | |
| 1907 | }; | |
| 1906 | // For items this `Span` will be populated, everything else it'll be None. | |
| 1907 | sugg_span | |
| 1908 | }; | |
| 1908 | 1909 | match sugg_span { |
| 1909 | 1910 | Some(span) => { |
| 1910 | 1911 | err.span_suggestion_verbose( |
compiler/rustc_resolve/src/ident.rs+1-1| ... | ... | @@ -644,7 +644,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 644 | 644 | } |
| 645 | 645 | } |
| 646 | 646 | Scope::ModuleGlobs(module, _) |
| 647 | if let ModuleKind::Def(_, def_id, _) = module.kind | |
| 647 | if let ModuleKind::Def(_, def_id, _, _) = module.kind | |
| 648 | 648 | && !def_id.is_local() => |
| 649 | 649 | { |
| 650 | 650 | // Fast path: external module decoding only creates non-glob declarations. |
compiler/rustc_resolve/src/late.rs+6-5| ... | ... | @@ -1941,7 +1941,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 1941 | 1941 | && let Some((module, _)) = &self.current_trait_ref |
| 1942 | 1942 | && let Some(ty) = &self.diag_metadata.current_self_type |
| 1943 | 1943 | && Some(true) == self.diag_metadata.in_non_gat_assoc_type |
| 1944 | && let crate::ModuleKind::Def(DefKind::Trait, trait_id, _) = module.kind | |
| 1944 | && let crate::ModuleKind::Def(DefKind::Trait, trait_id, _, _) = | |
| 1945 | module.kind | |
| 1945 | 1946 | { |
| 1946 | 1947 | if def_id_matches_path( |
| 1947 | 1948 | self.r.tcx, |
| ... | ... | @@ -4514,7 +4515,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 4514 | 4515 | parent_qself, |
| 4515 | 4516 | ); |
| 4516 | 4517 | |
| 4517 | let def_id = this.parent_scope.module.nearest_parent_mod(); | |
| 4518 | let node_id = this.parent_scope.module.nearest_parent_mod_node_id(); | |
| 4518 | 4519 | let instead = res.is_some(); |
| 4519 | 4520 | let (suggestion, const_err) = if let Some((start, end)) = |
| 4520 | 4521 | this.diag_metadata.in_range |
| ... | ... | @@ -4556,7 +4557,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 4556 | 4557 | let ue = UseError { |
| 4557 | 4558 | err, |
| 4558 | 4559 | candidates, |
| 4559 | def_id, | |
| 4560 | node_id, | |
| 4560 | 4561 | instead, |
| 4561 | 4562 | suggestion, |
| 4562 | 4563 | path: path.into(), |
| ... | ... | @@ -4645,7 +4646,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 4645 | 4646 | |
| 4646 | 4647 | parent_err.cancel(); |
| 4647 | 4648 | |
| 4648 | let def_id = this.parent_scope.module.nearest_parent_mod(); | |
| 4649 | let node_id = this.parent_scope.module.nearest_parent_mod_node_id(); | |
| 4649 | 4650 | |
| 4650 | 4651 | if this.should_report_errs() { |
| 4651 | 4652 | if candidates.is_empty() { |
| ... | ... | @@ -4670,7 +4671,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { |
| 4670 | 4671 | this.r.use_injections.push(UseError { |
| 4671 | 4672 | err, |
| 4672 | 4673 | candidates, |
| 4673 | def_id, | |
| 4674 | node_id, | |
| 4674 | 4675 | instead: false, |
| 4675 | 4676 | suggestion: None, |
| 4676 | 4677 | path: prefix_path.into(), |
compiler/rustc_resolve/src/lib.rs+23-14| ... | ... | @@ -543,7 +543,7 @@ enum ModuleKind { |
| 543 | 543 | /// The crate root will have `None` for the symbol. |
| 544 | 544 | /// * A trait or an enum (it implicitly contains associated types, methods and variant |
| 545 | 545 | /// constructors). |
| 546 | Def(DefKind, DefId, Option<Symbol>), | |
| 546 | Def(DefKind, DefId, NodeId, Option<Symbol>), | |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | impl ModuleKind { |
| ... | ... | @@ -557,7 +557,7 @@ impl ModuleKind { |
| 557 | 557 | |
| 558 | 558 | fn opt_def_id(&self) -> Option<DefId> { |
| 559 | 559 | match self { |
| 560 | ModuleKind::Def(_, def_id, _) => Some(*def_id), | |
| 560 | ModuleKind::Def(_, def_id, _, _) => Some(*def_id), | |
| 561 | 561 | _ => None, |
| 562 | 562 | } |
| 563 | 563 | } |
| ... | ... | @@ -726,7 +726,7 @@ impl<'ra> ModuleData<'ra> { |
| 726 | 726 | self_decl: Option<Decl<'ra>>, |
| 727 | 727 | ) -> Self { |
| 728 | 728 | let is_foreign = match kind { |
| 729 | ModuleKind::Def(_, def_id, _) => !def_id.is_local(), | |
| 729 | ModuleKind::Def(_, def_id, _, _) => !def_id.is_local(), | |
| 730 | 730 | ModuleKind::Block => false, |
| 731 | 731 | }; |
| 732 | 732 | ModuleData { |
| ... | ... | @@ -756,7 +756,7 @@ impl<'ra> ModuleData<'ra> { |
| 756 | 756 | |
| 757 | 757 | fn res(&self) -> Option<Res> { |
| 758 | 758 | match self.kind { |
| 759 | ModuleKind::Def(kind, def_id, _) => Some(Res::Def(kind, def_id)), | |
| 759 | ModuleKind::Def(kind, def_id, _, _) => Some(Res::Def(kind, def_id)), | |
| 760 | 760 | _ => None, |
| 761 | 761 | } |
| 762 | 762 | } |
| ... | ... | @@ -813,11 +813,11 @@ impl<'ra> Module<'ra> { |
| 813 | 813 | |
| 814 | 814 | // `self` resolves to the first module ancestor that `is_normal`. |
| 815 | 815 | fn is_normal(self) -> bool { |
| 816 | matches!(self.kind, ModuleKind::Def(DefKind::Mod, _, _)) | |
| 816 | matches!(self.kind, ModuleKind::Def(DefKind::Mod, _, _, _)) | |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | fn is_trait(self) -> bool { |
| 820 | matches!(self.kind, ModuleKind::Def(DefKind::Trait, _, _)) | |
| 820 | matches!(self.kind, ModuleKind::Def(DefKind::Trait, _, _, _)) | |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | fn nearest_item_scope(self) -> Module<'ra> { |
| ... | ... | @@ -833,11 +833,20 @@ impl<'ra> Module<'ra> { |
| 833 | 833 | /// This may be the crate root. |
| 834 | 834 | fn nearest_parent_mod(self) -> DefId { |
| 835 | 835 | match self.kind { |
| 836 | ModuleKind::Def(DefKind::Mod, def_id, _) => def_id, | |
| 836 | ModuleKind::Def(DefKind::Mod, def_id, _, _) => def_id, | |
| 837 | 837 | _ => self.parent.expect("non-root module without parent").nearest_parent_mod(), |
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | /// The [`NodeId`] of the nearest `mod` item ancestor (which may be this module). | |
| 842 | /// This may be the crate root. | |
| 843 | fn nearest_parent_mod_node_id(self) -> NodeId { | |
| 844 | match self.kind { | |
| 845 | ModuleKind::Def(DefKind::Mod, _, node_id, _) => node_id, | |
| 846 | _ => self.parent.expect("non-root module without parent").nearest_parent_mod_node_id(), | |
| 847 | } | |
| 848 | } | |
| 849 | ||
| 841 | 850 | fn is_ancestor_of(self, mut other: Self) -> bool { |
| 842 | 851 | while self != other { |
| 843 | 852 | if let Some(parent) = other.parent { |
| ... | ... | @@ -852,7 +861,7 @@ impl<'ra> Module<'ra> { |
| 852 | 861 | #[track_caller] |
| 853 | 862 | fn expect_local(self) -> LocalModule<'ra> { |
| 854 | 863 | match self.kind { |
| 855 | ModuleKind::Def(_, def_id, _) if !def_id.is_local() => { | |
| 864 | ModuleKind::Def(_, def_id, _, _) if !def_id.is_local() => { | |
| 856 | 865 | panic!("`Module::expect_local` is called on a non-local module: {self:?}") |
| 857 | 866 | } |
| 858 | 867 | ModuleKind::Def(..) | ModuleKind::Block => LocalModule(self.0), |
| ... | ... | @@ -862,7 +871,7 @@ impl<'ra> Module<'ra> { |
| 862 | 871 | #[track_caller] |
| 863 | 872 | fn expect_extern(self) -> ExternModule<'ra> { |
| 864 | 873 | match self.kind { |
| 865 | ModuleKind::Def(_, def_id, _) if !def_id.is_local() => ExternModule(self.0), | |
| 874 | ModuleKind::Def(_, def_id, _, _) if !def_id.is_local() => ExternModule(self.0), | |
| 866 | 875 | ModuleKind::Def(..) | ModuleKind::Block => { |
| 867 | 876 | panic!("`Module::expect_extern` is called on a local module: {self:?}") |
| 868 | 877 | } |
| ... | ... | @@ -992,8 +1001,8 @@ struct UseError<'a> { |
| 992 | 1001 | err: Diag<'a>, |
| 993 | 1002 | /// Candidates which user could `use` to access the missing type. |
| 994 | 1003 | candidates: Vec<ImportSuggestion>, |
| 995 | /// The `DefId` of the module to place the use-statements in. | |
| 996 | def_id: DefId, | |
| 1004 | /// The `NodeId` of the module to place the use-statements in. | |
| 1005 | node_id: NodeId, | |
| 997 | 1006 | /// Whether the diagnostic should say "instead" (as in `consider importing ... instead`). |
| 998 | 1007 | instead: bool, |
| 999 | 1008 | /// Extra free-form suggestion. |
| ... | ... | @@ -1551,7 +1560,7 @@ impl<'ra> ResolverArenas<'ra> { |
| 1551 | 1560 | no_implicit_prelude: bool, |
| 1552 | 1561 | ) -> Module<'ra> { |
| 1553 | 1562 | let self_decl = match kind { |
| 1554 | ModuleKind::Def(def_kind, def_id, _) => Some(self.new_def_decl( | |
| 1563 | ModuleKind::Def(def_kind, def_id, _, _) => Some(self.new_def_decl( | |
| 1555 | 1564 | Res::Def(def_kind, def_id), |
| 1556 | 1565 | vis, |
| 1557 | 1566 | span, |
| ... | ... | @@ -1732,7 +1741,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1732 | 1741 | let root_def_id = CRATE_DEF_ID.to_def_id(); |
| 1733 | 1742 | let graph_root = arenas.new_module( |
| 1734 | 1743 | None, |
| 1735 | ModuleKind::Def(DefKind::Mod, root_def_id, None), | |
| 1744 | ModuleKind::Def(DefKind::Mod, root_def_id, CRATE_NODE_ID, None), | |
| 1736 | 1745 | Visibility::Public, |
| 1737 | 1746 | ExpnId::root(), |
| 1738 | 1747 | crate_span, |
| ... | ... | @@ -1743,7 +1752,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1743 | 1752 | let local_module_map = FxIndexMap::from_iter([(CRATE_DEF_ID, graph_root)]); |
| 1744 | 1753 | let empty_module = arenas.new_module( |
| 1745 | 1754 | None, |
| 1746 | ModuleKind::Def(DefKind::Mod, root_def_id, None), | |
| 1755 | ModuleKind::Def(DefKind::Mod, root_def_id, CRATE_NODE_ID, None), | |
| 1747 | 1756 | Visibility::Public, |
| 1748 | 1757 | ExpnId::root(), |
| 1749 | 1758 | DUMMY_SP, |
compiler/rustc_resolve/src/macros.rs+1-1| ... | ... | @@ -1185,7 +1185,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { |
| 1185 | 1185 | self.get_mut().record_use(ident, fallback_binding, Used::Other); |
| 1186 | 1186 | } else { |
| 1187 | 1187 | let location = match parent_scope.module.kind { |
| 1188 | ModuleKind::Def(kind, def_id, name) => { | |
| 1188 | ModuleKind::Def(kind, def_id, _, name) => { | |
| 1189 | 1189 | if let Some(name) = name { |
| 1190 | 1190 | format!("{} `{name}`", kind.descr(def_id)) |
| 1191 | 1191 | } else { |
compiler/rustc_target/src/target_features.rs+33-3| ... | ... | @@ -17,6 +17,13 @@ pub enum Stability { |
| 17 | 17 | /// This target feature is stable, it can be used in `#[target_feature]` and |
| 18 | 18 | /// `#[cfg(target_feature)]`. |
| 19 | 19 | Stable, |
| 20 | /// This target feature is cfg-stable. It can be used for `#[cfg(target_feature)]` on stable, | |
| 21 | /// but using it in `#[target_feature]` requires the given nightly feature. | |
| 22 | CfgStableToggleUnstable( | |
| 23 | /// This must be a *language* feature, or else rustc will ICE when reporting a missing | |
| 24 | /// feature gate! | |
| 25 | Symbol, | |
| 26 | ), | |
| 20 | 27 | /// This target feature is unstable. It is only present in `#[cfg(target_feature)]` on |
| 21 | 28 | /// nightly and using it in `#[target_feature]` requires enabling the given nightly feature. |
| 22 | 29 | Unstable( |
| ... | ... | @@ -37,7 +44,12 @@ impl Stability { |
| 37 | 44 | /// (It might still be nightly-only even if this returns `true`, so make sure to also check |
| 38 | 45 | /// `requires_nightly`.) |
| 39 | 46 | pub fn in_cfg(&self) -> bool { |
| 40 | matches!(self, Stability::Stable | Stability::Unstable { .. }) | |
| 47 | matches!( | |
| 48 | self, | |
| 49 | Stability::Stable | |
| 50 | | Stability::CfgStableToggleUnstable { .. } | |
| 51 | | Stability::Unstable { .. } | |
| 52 | ) | |
| 41 | 53 | } |
| 42 | 54 | |
| 43 | 55 | /// Returns the nightly feature that is required to toggle this target feature via |
| ... | ... | @@ -48,20 +60,38 @@ impl Stability { |
| 48 | 60 | /// Before calling this, ensure the feature is even permitted for this use: |
| 49 | 61 | /// - for `#[target_feature]`/`-Ctarget-feature`, check `toggle_allowed()` |
| 50 | 62 | /// - for `cfg(target_feature)`, check `in_cfg()` |
| 51 | pub fn requires_nightly(&self) -> Option<Symbol> { | |
| 63 | /// | |
| 64 | /// The `in_cfg` parameter is used to determine whether it will be used in | |
| 65 | /// `cfg(target_feature)` (true) or `#[target_feature]`/`-Ctarget-feature` (false) | |
| 66 | pub fn requires_nightly(&self, in_cfg: bool) -> Option<Symbol> { | |
| 52 | 67 | match *self { |
| 53 | 68 | Stability::Unstable(nightly_feature) => Some(nightly_feature), |
| 69 | Stability::CfgStableToggleUnstable(nightly_feature) => { | |
| 70 | if in_cfg { | |
| 71 | None | |
| 72 | } else { | |
| 73 | Some(nightly_feature) | |
| 74 | } | |
| 75 | } | |
| 54 | 76 | Stability::Stable { .. } => None, |
| 55 | 77 | Stability::Forbidden { .. } => panic!("forbidden features should not reach this far"), |
| 56 | 78 | } |
| 57 | 79 | } |
| 58 | 80 | |
| 81 | /// Returns whether the feature is cfg-stable but still requires a nightly feature gate to | |
| 82 | /// be used in `#[target_feature]`/`-Ctarget-feature`. | |
| 83 | pub fn is_cfg_stable_toggle_unstable(&self) -> bool { | |
| 84 | matches!(self, Stability::CfgStableToggleUnstable { .. }) | |
| 85 | } | |
| 86 | ||
| 59 | 87 | /// Returns whether the feature may be toggled via `#[target_feature]` or `-Ctarget-feature`. |
| 60 | 88 | /// (It might still be nightly-only even if this returns `true`, so make sure to also check |
| 61 | 89 | /// `requires_nightly`.) |
| 62 | 90 | pub fn toggle_allowed(&self) -> Result<(), &'static str> { |
| 63 | 91 | match self { |
| 64 | Stability::Unstable(_) | Stability::Stable { .. } => Ok(()), | |
| 92 | Stability::Unstable(_) | |
| 93 | | Stability::CfgStableToggleUnstable(_) | |
| 94 | | Stability::Stable { .. } => Ok(()), | |
| 65 | 95 | Stability::Forbidden { reason } => Err(reason), |
| 66 | 96 | } |
| 67 | 97 | } |
library/core/src/any.rs+14-4| ... | ... | @@ -1007,18 +1007,23 @@ pub const fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str { |
| 1007 | 1007 | #[must_use] |
| 1008 | 1008 | #[unstable(feature = "try_as_dyn", issue = "144361")] |
| 1009 | 1009 | pub const fn try_as_dyn< |
| 1010 | T: Any + 'static, | |
| 1010 | T: Any + ?Sized + 'static, | |
| 1011 | 1011 | U: ptr::Pointee<Metadata = ptr::DynMetadata<U>> + ?Sized + 'static, |
| 1012 | 1012 | >( |
| 1013 | 1013 | t: &T, |
| 1014 | 1014 | ) -> Option<&U> { |
| 1015 | // For unsized `T`, `trait_info_of` always returns `None` (vtable lookup is | |
| 1016 | // only supported for sized types). The function therefore unconditionally | |
| 1017 | // returns `None` in that case. | |
| 1015 | 1018 | let vtable: Option<ptr::DynMetadata<U>> = |
| 1016 | 1019 | const { TypeId::of::<T>().trait_info_of::<U>().as_ref().map(TraitImpl::get_vtable) }; |
| 1017 | 1020 | match vtable { |
| 1018 | 1021 | Some(dyn_metadata) => { |
| 1019 | let pointer = ptr::from_raw_parts(t, dyn_metadata); | |
| 1022 | let pointer = ptr::from_raw_parts(t as *const T as *const (), dyn_metadata); | |
| 1020 | 1023 | // SAFETY: `t` is a reference to a type, so we know it is valid. |
| 1021 | 1024 | // `dyn_metadata` is a vtable for T, implementing the trait of `U`. |
| 1025 | // `T` is sized here because `trait_info_of` only returns `Some` for sized types, | |
| 1026 | // so the thin data pointer fully describes the value. | |
| 1022 | 1027 | Some(unsafe { &*pointer }) |
| 1023 | 1028 | } |
| 1024 | 1029 | None => None, |
| ... | ... | @@ -1061,18 +1066,23 @@ pub const fn try_as_dyn< |
| 1061 | 1066 | #[must_use] |
| 1062 | 1067 | #[unstable(feature = "try_as_dyn", issue = "144361")] |
| 1063 | 1068 | pub const fn try_as_dyn_mut< |
| 1064 | T: Any + 'static, | |
| 1069 | T: Any + ?Sized + 'static, | |
| 1065 | 1070 | U: ptr::Pointee<Metadata = ptr::DynMetadata<U>> + ?Sized + 'static, |
| 1066 | 1071 | >( |
| 1067 | 1072 | t: &mut T, |
| 1068 | 1073 | ) -> Option<&mut U> { |
| 1074 | // For unsized `T`, `trait_info_of` always returns `None` (vtable lookup is | |
| 1075 | // only supported for sized types). The function therefore unconditionally | |
| 1076 | // returns `None` in that case. | |
| 1069 | 1077 | let vtable: Option<ptr::DynMetadata<U>> = |
| 1070 | 1078 | const { TypeId::of::<T>().trait_info_of::<U>().as_ref().map(TraitImpl::get_vtable) }; |
| 1071 | 1079 | match vtable { |
| 1072 | 1080 | Some(dyn_metadata) => { |
| 1073 | let pointer = ptr::from_raw_parts_mut(t, dyn_metadata); | |
| 1081 | let pointer = ptr::from_raw_parts_mut(t as *mut T as *mut (), dyn_metadata); | |
| 1074 | 1082 | // SAFETY: `t` is a reference to a type, so we know it is valid. |
| 1075 | 1083 | // `dyn_metadata` is a vtable for T, implementing the trait of `U`. |
| 1084 | // `T` is sized here because `trait_info_of` only returns `Some` for sized types, | |
| 1085 | // so the thin data pointer fully describes the value. | |
| 1076 | 1086 | Some(unsafe { &mut *pointer }) |
| 1077 | 1087 | } |
| 1078 | 1088 | None => None, |
library/core/src/io/error.rs+18-3| ... | ... | @@ -21,6 +21,10 @@ pub type RawOsError = cfg_select! { |
| 21 | 21 | /// This list is intended to grow over time and it is not recommended to |
| 22 | 22 | /// exhaustively match against it. |
| 23 | 23 | /// |
| 24 | /// It is used with the [`io::Error`][error] type. | |
| 25 | /// | |
| 26 | /// [error]: ../../std/io/struct.Error.html | |
| 27 | /// | |
| 24 | 28 | /// # Handling errors and matching on `ErrorKind` |
| 25 | 29 | /// |
| 26 | 30 | /// In application code, use `match` for the `ErrorKind` values you are |
| ... | ... | @@ -135,12 +139,13 @@ pub enum ErrorKind { |
| 135 | 139 | #[stable(feature = "rust1", since = "1.0.0")] |
| 136 | 140 | TimedOut, |
| 137 | 141 | /// An error returned when an operation could not be completed because a |
| 138 | /// call to an underlying writer returned [`Ok(0)`]. | |
| 142 | /// call to [`write`][write] returned [`Ok(0)`]. | |
| 139 | 143 | /// |
| 140 | 144 | /// This typically means that an operation could only succeed if it wrote a |
| 141 | 145 | /// particular number of bytes but only a smaller number of bytes could be |
| 142 | 146 | /// written. |
| 143 | 147 | /// |
| 148 | /// [write]: ../../std/io/trait.Write.html#tymethod.write | |
| 144 | 149 | /// [`Ok(0)`]: Ok |
| 145 | 150 | #[stable(feature = "rust1", since = "1.0.0")] |
| 146 | 151 | WriteZero, |
| ... | ... | @@ -239,7 +244,7 @@ pub enum ErrorKind { |
| 239 | 244 | // |
| 240 | 245 | /// A custom error that does not fall under any other I/O error kind. |
| 241 | 246 | /// |
| 242 | /// This can be used to construct your own errors that do not match any | |
| 247 | /// This can be used to construct your own [`Error`][error]s that do not match any | |
| 243 | 248 | /// [`ErrorKind`]. |
| 244 | 249 | /// |
| 245 | 250 | /// This [`ErrorKind`] is not used by the standard library. |
| ... | ... | @@ -247,6 +252,8 @@ pub enum ErrorKind { |
| 247 | 252 | /// Errors from the standard library that do not fall under any of the I/O |
| 248 | 253 | /// error kinds cannot be `match`ed on, and will only match a wildcard (`_`) pattern. |
| 249 | 254 | /// New [`ErrorKind`]s might be added in the future for some of those. |
| 255 | /// | |
| 256 | /// [error]: ../../std/io/struct.Error.html | |
| 250 | 257 | #[stable(feature = "rust1", since = "1.0.0")] |
| 251 | 258 | Other, |
| 252 | 259 | |
| ... | ... | @@ -379,7 +386,15 @@ impl ErrorKind { |
| 379 | 386 | |
| 380 | 387 | #[stable(feature = "io_errorkind_display", since = "1.60.0")] |
| 381 | 388 | impl fmt::Display for ErrorKind { |
| 382 | /// Shows a human-readable description of the `ErrorKind`. | |
| 389 | /// Shows a human-readable description of the [`ErrorKind`]. | |
| 390 | /// | |
| 391 | /// This is similar to `impl Display for Error`, but doesn't require first converting to Error. | |
| 392 | /// | |
| 393 | /// # Examples | |
| 394 | /// ``` | |
| 395 | /// use core::io::ErrorKind; | |
| 396 | /// assert_eq!("entity not found", ErrorKind::NotFound.to_string()); | |
| 397 | /// ``` | |
| 383 | 398 | fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 384 | 399 | fmt.write_str(self.as_str()) |
| 385 | 400 | } |
library/core/src/str/lossy.rs+1-6| ... | ... | @@ -211,12 +211,7 @@ impl<'a> Iterator for Utf8Chunks<'a> { |
| 211 | 211 | |
| 212 | 212 | let mut i = 0; |
| 213 | 213 | let mut valid_up_to = 0; |
| 214 | while i < self.source.len() { | |
| 215 | // SAFETY: `i < self.source.len()` per previous line. | |
| 216 | // For some reason the following are both significantly slower: | |
| 217 | // while let Some(&byte) = self.source.get(i) { | |
| 218 | // while let Some(byte) = self.source.get(i).copied() { | |
| 219 | let byte = unsafe { *self.source.get_unchecked(i) }; | |
| 214 | while let Some(byte) = self.source.get(i).copied() { | |
| 220 | 215 | i += 1; |
| 221 | 216 | |
| 222 | 217 | if byte < 128 { |
package.json+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | { |
| 2 | 2 | "dependencies": { |
| 3 | "browser-ui-test": "^0.23.3", | |
| 3 | "browser-ui-test": "^0.23.5", | |
| 4 | 4 | "es-check": "^9.4.4", |
| 5 | 5 | "eslint": "^8.57.1", |
| 6 | 6 | "typescript": "^5.8.3" |
src/doc/reference+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | Subproject commit 8c88f9d0bdd75ffdc0691676d83212ae22a18cee | |
| 1 | Subproject commit 581920f9109f141b88b860b3e1e8359e3896a150 |
src/doc/unstable-book/src/language-features/generic-const-args.md created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | # generic_const_args | |
| 2 | ||
| 3 | Allows using generics in more complex const expressions, based on definitional equality. | |
| 4 | ||
| 5 | The tracking issue for this feature is: [#151972] | |
| 6 | ||
| 7 | [#151972]: https://github.com/rust-lang/rust/issues/151972 | |
| 8 | ||
| 9 | ------------------------ | |
| 10 | ||
| 11 | Warning: This feature is incomplete; its design and syntax may change. | |
| 12 | ||
| 13 | This feature enables many of the same use cases supported by [generic_const_exprs], | |
| 14 | but based on the machinery developed for [min_generic_const_args]. In a way, it is | |
| 15 | meant to be an interim successor for GCE (though it might not currently support all | |
| 16 | the valid cases that supported by GCE). | |
| 17 | ||
| 18 | See also: [generic_const_items] | |
| 19 | ||
| 20 | [min_generic_const_args]: min-generic-const-args.md | |
| 21 | [generic_const_exprs]: generic-const-exprs.md | |
| 22 | [generic_const_items]: generic-const-items.md | |
| 23 | ||
| 24 | ## Examples | |
| 25 | ||
| 26 | ```rust | |
| 27 | #![feature(generic_const_items)] | |
| 28 | #![feature(min_generic_const_args)] | |
| 29 | #![feature(generic_const_args)] | |
| 30 | #![expect(incomplete_features)] | |
| 31 | ||
| 32 | type const ADD1<const N: usize>: usize = const { N + 1 }; | |
| 33 | ||
| 34 | type const INC<const N: usize>: usize = ADD1::<N>; | |
| 35 | ||
| 36 | const ARR: [(); ADD1::<0>] = [(); INC::<0>]; | |
| 37 | ``` |
src/doc/unstable-book/src/language-features/generic-const-exprs.md created+73| ... | ... | @@ -0,0 +1,73 @@ |
| 1 | # generic_const_exprs | |
| 2 | ||
| 3 | Allows non-trivial generic constants which have to be shown to successfully evaluate | |
| 4 | to a value by being part of an item signature. | |
| 5 | ||
| 6 | The tracking issue for this feature is: [#76560] | |
| 7 | ||
| 8 | ||
| 9 | [#76560]: https://github.com/rust-lang/rust/issues/76560 | |
| 10 | ||
| 11 | ------------------------ | |
| 12 | ||
| 13 | Warning: This feature is incomplete; its design and syntax may change. | |
| 14 | ||
| 15 | See also: [min_generic_const_args], [generic_const_args] | |
| 16 | ||
| 17 | [min_generic_const_args]: min-generic-const-args.md | |
| 18 | [generic_const_args]: generic-const-args.md | |
| 19 | ||
| 20 | ## Examples | |
| 21 | ||
| 22 | ```rust | |
| 23 | #![allow(incomplete_features)] | |
| 24 | #![feature(generic_const_exprs)] | |
| 25 | ||
| 26 | // Use parameters that depend on a generic argument. | |
| 27 | struct Foo<const N: usize> | |
| 28 | where | |
| 29 | [(); N + 1]:, | |
| 30 | { | |
| 31 | array: [usize; N + 1], | |
| 32 | } | |
| 33 | ||
| 34 | // Use generic parameters in const operations. | |
| 35 | trait Bar { | |
| 36 | const X: usize; | |
| 37 | const Y: usize; | |
| 38 | } | |
| 39 | ||
| 40 | // Note `B::X * B::Y`. | |
| 41 | const fn baz<B: Bar>(x: [usize; B::X], y: [usize; B::Y]) -> [usize; B::X * B::Y] { | |
| 42 | let mut out = [0; B::X * B::Y]; | |
| 43 | let mut i = 0; | |
| 44 | while i < B::Y { | |
| 45 | let mut j = 0; | |
| 46 | while j < B::X { | |
| 47 | out[i * B::X + j] = y[i].saturating_mul(x[j]); | |
| 48 | j += 1; | |
| 49 | } | |
| 50 | i += 1; | |
| 51 | } | |
| 52 | out | |
| 53 | } | |
| 54 | ||
| 55 | ||
| 56 | // Create a new type based on a generic argument. | |
| 57 | pub struct Grow<const N: usize> { | |
| 58 | arr: [usize; N], | |
| 59 | } | |
| 60 | ||
| 61 | impl<const N: usize> Grow<N> { | |
| 62 | pub const fn grow(self, val: usize) -> Grow<{ N + 1 }> { | |
| 63 | let mut new_arr = [0; { N + 1 }]; | |
| 64 | let mut idx = 0; | |
| 65 | while idx < N { | |
| 66 | new_arr[idx] = self.arr[idx]; | |
| 67 | idx += 1; | |
| 68 | } | |
| 69 | new_arr[N] = val; | |
| 70 | Grow { arr: new_arr } | |
| 71 | } | |
| 72 | } | |
| 73 | ``` |
src/doc/unstable-book/src/language-features/generic-const-items.md created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | # generic_const_items | |
| 2 | ||
| 3 | Allows generic parameters and where-clauses on free & associated const items. | |
| 4 | ||
| 5 | The tracking issue for this feature is: [#113521] | |
| 6 | ||
| 7 | [#113521]: https://github.com/rust-lang/rust/issues/113521 | |
| 8 | ||
| 9 | ------------------------ | |
| 10 | ||
| 11 | Warning: This feature is an [experiment] and lacks an RFC. | |
| 12 | There are no guarantees that it will ever be stabilized. | |
| 13 | ||
| 14 | See also: [generic_const_exprs], [min_generic_const_args]. | |
| 15 | ||
| 16 | [experiment]: https://lang-team.rust-lang.org/how_to/experiment.html | |
| 17 | [generic_const_exprs]: generic-const-exprs.md | |
| 18 | [min_generic_const_args]: min-generic-const-args.md | |
| 19 | ||
| 20 | ## Examples | |
| 21 | ||
| 22 | ### Generic constant values | |
| 23 | ||
| 24 | ```rust | |
| 25 | #![allow(incomplete_features)] | |
| 26 | #![feature(generic_const_items)] | |
| 27 | ||
| 28 | const GENERIC_VAL<const ARG: usize>: usize = ARG + 1; | |
| 29 | ||
| 30 | #[test] | |
| 31 | fn generic_const_arg() { | |
| 32 | assert_eq!(GENERIC_VAL::<1>, 2); | |
| 33 | assert_eq!(GENERIC_VAL::<2>, 3); | |
| 34 | } | |
| 35 | ``` | |
| 36 | ||
| 37 | ### Conditional constants | |
| 38 | ||
| 39 | ```rust | |
| 40 | #![allow(incomplete_features)] | |
| 41 | #![feature(generic_const_items)] | |
| 42 | ||
| 43 | // `GENERIC_VAL::<0>` will fail to compile | |
| 44 | const GENERIC_VAL<const ARG: usize>: usize = if ARG > 0 { ARG + 1 } else { panic!("0 value") }; | |
| 45 | ||
| 46 | // Will fail to compile if the `Copy` derive is removed. | |
| 47 | const COPY_MARKER<C: Copy>: () = (); | |
| 48 | ||
| 49 | #[derive(Clone, Copy)] | |
| 50 | struct Foo; | |
| 51 | ||
| 52 | const FOO_IS_COPY: () = COPY_MARKER::<Foo>; | |
| 53 | ``` |
src/doc/unstable-book/src/language-features/min-generic-const-args.md created+110| ... | ... | @@ -0,0 +1,110 @@ |
| 1 | # min_generic_const_args | |
| 2 | ||
| 3 | Enables the generic const args MVP (paths to type const items and constructors for ADTs and primitives). | |
| 4 | ||
| 5 | The tracking issue for this feature is: [#132980] | |
| 6 | ||
| 7 | [#132980]: https://github.com/rust-lang/rust/issues/132980 | |
| 8 | ||
| 9 | ------------------------ | |
| 10 | ||
| 11 | Warning: This feature is incomplete; its design and syntax may change. | |
| 12 | ||
| 13 | This feature acts as a minimal alternative to [generic_const_exprs] that allows a smaller subset of functionality, | |
| 14 | and uses a different approach for implementation. It is intentionally more restrictive, which helps with avoiding edge | |
| 15 | cases that make the `generic_const_exprs` hard to implement properly. See [Feature background][feature_background] | |
| 16 | for more details. | |
| 17 | ||
| 18 | Related features: [generic_const_args], [generic_const_items]. | |
| 19 | ||
| 20 | [feature_background]: https://github.com/rust-lang/project-const-generics/blob/main/documents/min_const_generics_plan.md | |
| 21 | [generic_const_exprs]: generic-const-exprs.md | |
| 22 | [generic_const_args]: generic-const-args.md | |
| 23 | [generic_const_items]: generic-const-items.md | |
| 24 | ||
| 25 | ## `type const` syntax | |
| 26 | ||
| 27 | This feature introduces new syntax: `type const`. | |
| 28 | Constants marked as `type const` are allowed to be used in type contexts, e.g.: | |
| 29 | ||
| 30 | ```compile_fail | |
| 31 | #![allow(incomplete_features)] | |
| 32 | #![feature(min_generic_const_args)] | |
| 33 | ||
| 34 | type const X: usize = 1; | |
| 35 | const Y: usize = 1; | |
| 36 | ||
| 37 | struct Foo { | |
| 38 | good_arr: [(); X], // Allowed | |
| 39 | bad_arr: [(); Y], // Will not compile, `Y` must be `type const`. | |
| 40 | } | |
| 41 | ``` | |
| 42 | ||
| 43 | ## Examples | |
| 44 | ||
| 45 | ```rust | |
| 46 | #![allow(incomplete_features)] | |
| 47 | #![feature(min_generic_const_args)] | |
| 48 | ||
| 49 | trait Bar { | |
| 50 | type const VAL: usize; | |
| 51 | type const VAL2: usize; | |
| 52 | } | |
| 53 | ||
| 54 | struct Baz; | |
| 55 | ||
| 56 | impl Bar for Baz { | |
| 57 | type const VAL: usize = 2; | |
| 58 | type const VAL2: usize = const { Self::VAL * 2 }; | |
| 59 | } | |
| 60 | ||
| 61 | struct Foo<B: Bar> { | |
| 62 | arr1: [usize; B::VAL], | |
| 63 | arr2: [usize; B::VAL2], | |
| 64 | } | |
| 65 | ``` | |
| 66 | ||
| 67 | Note that with [generic_const_exprs] the same example would look as follows: | |
| 68 | ||
| 69 | ```rust | |
| 70 | #![allow(incomplete_features)] | |
| 71 | #![feature(generic_const_exprs)] | |
| 72 | ||
| 73 | trait Bar { | |
| 74 | const VAL: usize; | |
| 75 | const VAL2: usize; | |
| 76 | } | |
| 77 | ||
| 78 | struct Baz; | |
| 79 | ||
| 80 | impl Bar for Baz { | |
| 81 | const VAL: usize = 2; | |
| 82 | const VAL2: usize = const { Self::VAL * 2 }; | |
| 83 | } | |
| 84 | ||
| 85 | struct Foo<B: Bar> | |
| 86 | where | |
| 87 | [(); B::VAL]:, | |
| 88 | [(); B::VAL2]:, | |
| 89 | { | |
| 90 | arr1: [usize; B::VAL], | |
| 91 | arr2: [usize; B::VAL2], | |
| 92 | } | |
| 93 | ``` | |
| 94 | ||
| 95 | Use of const functions is allowed: | |
| 96 | ||
| 97 | ```rust | |
| 98 | #![allow(incomplete_features)] | |
| 99 | #![feature(min_generic_const_args)] | |
| 100 | ||
| 101 | const VAL: usize = 1; | |
| 102 | ||
| 103 | const fn inc(val: usize) -> usize { | |
| 104 | val + 1 | |
| 105 | } | |
| 106 | ||
| 107 | type const INC: usize = const { inc(VAL) }; | |
| 108 | ||
| 109 | const ARR: [usize; INC] = [0; INC]; | |
| 110 | ``` |
tests/assembly-llvm/c-variadic/avr.rs created+220| ... | ... | @@ -0,0 +1,220 @@ |
| 1 | //@ add-minicore | |
| 2 | //@ assembly-output: emit-asm | |
| 3 | // | |
| 4 | //@ revisions: AVR | |
| 5 | //@ [AVR] compile-flags: -Copt-level=3 --target=avr-none -Ctarget-cpu=atmega328p | |
| 6 | //@ [AVR] needs-llvm-components: avr | |
| 7 | #![feature(c_variadic, c_variadic_experimental_arch, no_core, lang_items, intrinsics, rustc_attrs)] | |
| 8 | #![no_core] | |
| 9 | #![crate_type = "lib"] | |
| 10 | ||
| 11 | // Check that rustc and clang output match, see https://godbolt.org/z/1MvxoceeT. | |
| 12 | ||
| 13 | extern crate minicore; | |
| 14 | use minicore::*; | |
| 15 | ||
| 16 | #[lang = "va_arg_safe"] | |
| 17 | pub unsafe trait VaArgSafe {} | |
| 18 | ||
| 19 | unsafe impl VaArgSafe for i16 {} | |
| 20 | unsafe impl VaArgSafe for i32 {} | |
| 21 | unsafe impl VaArgSafe for i64 {} | |
| 22 | unsafe impl VaArgSafe for f32 {} | |
| 23 | unsafe impl VaArgSafe for f64 {} | |
| 24 | unsafe impl<T> VaArgSafe for *const T {} | |
| 25 | ||
| 26 | #[repr(transparent)] | |
| 27 | struct VaListInner { | |
| 28 | ptr: *const c_void, | |
| 29 | } | |
| 30 | ||
| 31 | #[repr(transparent)] | |
| 32 | #[lang = "va_list"] | |
| 33 | pub struct VaList<'a> { | |
| 34 | inner: VaListInner, | |
| 35 | _marker: PhantomData<&'a mut ()>, | |
| 36 | } | |
| 37 | ||
| 38 | #[rustc_intrinsic] | |
| 39 | #[rustc_nounwind] | |
| 40 | pub const unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaList<'_>) -> T; | |
| 41 | ||
| 42 | #[unsafe(no_mangle)] | |
| 43 | unsafe extern "C" fn read_f32(ap: &mut VaList<'_>) -> f32 { | |
| 44 | // CHECK-LABEL: read_f32 | |
| 45 | // | |
| 46 | // AVR: movw r30, r24 | |
| 47 | // AVR-NEXT: ld r24, Z | |
| 48 | // AVR-NEXT: ldd r25, Z+1 | |
| 49 | // AVR-NEXT: movw r26, r24 | |
| 50 | // AVR-NEXT: adiw r26, 2 | |
| 51 | // AVR-NEXT: std Z+1, r27 | |
| 52 | // AVR-NEXT: st Z, r26 | |
| 53 | // AVR-NEXT: movw r20, r30 | |
| 54 | // AVR-NEXT: movw r18, r24 | |
| 55 | // AVR-NEXT: movw r30, r18 | |
| 56 | // AVR-NEXT: ld r22, Z | |
| 57 | // AVR-NEXT: ldd r23, Z+1 | |
| 58 | // AVR-NEXT: adiw r24, 4 | |
| 59 | // AVR-NEXT: movw r30, r20 | |
| 60 | // AVR-NEXT: std Z+1, r25 | |
| 61 | // AVR-NEXT: st Z, r24 | |
| 62 | // AVR-NEXT: movw r30, r18 | |
| 63 | // AVR-NEXT: ldd r24, Z+2 | |
| 64 | // AVR-NEXT: ldd r25, Z+3 | |
| 65 | // AVR-NEXT: ret | |
| 66 | va_arg(ap) | |
| 67 | } | |
| 68 | ||
| 69 | #[unsafe(no_mangle)] | |
| 70 | unsafe extern "C" fn read_f64(ap: &mut VaList<'_>) -> f64 { | |
| 71 | // CHECK-LABEL: read_f64 | |
| 72 | // | |
| 73 | // AVR: push r14 | |
| 74 | // AVR-NEXT: push r15 | |
| 75 | // AVR-NEXT: push r16 | |
| 76 | // AVR-NEXT: push r17 | |
| 77 | // AVR-NEXT: movw r30, r24 | |
| 78 | // AVR-NEXT: ld r24, Z | |
| 79 | // AVR-NEXT: ldd r25, Z+1 | |
| 80 | // AVR-NEXT: movw r26, r24 | |
| 81 | // AVR-NEXT: adiw r26, 2 | |
| 82 | // AVR-NEXT: std Z+1, r27 | |
| 83 | // AVR-NEXT: st Z, r26 | |
| 84 | // AVR-NEXT: movw r14, r30 | |
| 85 | // AVR-NEXT: movw r16, r24 | |
| 86 | // AVR-NEXT: movw r30, r16 | |
| 87 | // AVR-NEXT: ld r18, Z | |
| 88 | // AVR-NEXT: ldd r19, Z+1 | |
| 89 | // AVR-NEXT: movw r26, r24 | |
| 90 | // AVR-NEXT: adiw r26, 4 | |
| 91 | // AVR-NEXT: movw r30, r14 | |
| 92 | // AVR-NEXT: std Z+1, r27 | |
| 93 | // AVR-NEXT: st Z, r26 | |
| 94 | // AVR-NEXT: movw r30, r16 | |
| 95 | // AVR-NEXT: ldd r20, Z+2 | |
| 96 | // AVR-NEXT: ldd r21, Z+3 | |
| 97 | // AVR-NEXT: movw r26, r24 | |
| 98 | // AVR-NEXT: adiw r26, 6 | |
| 99 | // AVR-NEXT: movw r30, r14 | |
| 100 | // AVR-NEXT: std Z+1, r27 | |
| 101 | // AVR-NEXT: st Z, r26 | |
| 102 | // AVR-NEXT: movw r30, r16 | |
| 103 | // AVR-NEXT: ldd r22, Z+4 | |
| 104 | // AVR-NEXT: ldd r23, Z+5 | |
| 105 | // AVR-NEXT: adiw r24, 8 | |
| 106 | // AVR-NEXT: movw r30, r14 | |
| 107 | // AVR-NEXT: std Z+1, r25 | |
| 108 | // AVR-NEXT: st Z, r24 | |
| 109 | // AVR-NEXT: movw r30, r16 | |
| 110 | // AVR-NEXT: ldd r24, Z+6 | |
| 111 | // AVR-NEXT: ldd r25, Z+7 | |
| 112 | // AVR-NEXT: pop r17 | |
| 113 | // AVR-NEXT: pop r16 | |
| 114 | // AVR-NEXT: pop r15 | |
| 115 | // AVR-NEXT: pop r14 | |
| 116 | // AVR-NEXT: ret | |
| 117 | va_arg(ap) | |
| 118 | } | |
| 119 | ||
| 120 | #[unsafe(no_mangle)] | |
| 121 | unsafe extern "C" fn read_i16(ap: &mut VaList<'_>) -> i16 { | |
| 122 | // CHECK-LABEL: read_i16 | |
| 123 | // | |
| 124 | // AVR: movw r30, r24 | |
| 125 | // AVR-NEXT: ld r24, Z | |
| 126 | // AVR-NEXT: ldd r25, Z+1 | |
| 127 | // AVR-NEXT: movw r26, r24 | |
| 128 | // AVR-NEXT: adiw r26, 2 | |
| 129 | // AVR-NEXT: std Z+1, r27 | |
| 130 | // AVR-NEXT: st Z, r26 | |
| 131 | // AVR-NEXT: movw r30, r24 | |
| 132 | // AVR-NEXT: ld r24, Z | |
| 133 | // AVR-NEXT: ldd r25, Z+1 | |
| 134 | // AVR-NEXT: ret | |
| 135 | va_arg(ap) | |
| 136 | } | |
| 137 | ||
| 138 | #[unsafe(no_mangle)] | |
| 139 | unsafe extern "C" fn read_i32(ap: &mut VaList<'_>) -> i32 { | |
| 140 | // CHECK-LABEL: read_i32 | |
| 141 | // | |
| 142 | // AVR: movw r30, r24 | |
| 143 | // AVR-NEXT: ld r24, Z | |
| 144 | // AVR-NEXT: ldd r25, Z+1 | |
| 145 | // AVR-NEXT: movw r26, r24 | |
| 146 | // AVR-NEXT: adiw r26, 2 | |
| 147 | // AVR-NEXT: std Z+1, r27 | |
| 148 | // AVR-NEXT: st Z, r26 | |
| 149 | // AVR-NEXT: movw r20, r30 | |
| 150 | // AVR-NEXT: movw r18, r24 | |
| 151 | // AVR-NEXT: movw r30, r18 | |
| 152 | // AVR-NEXT: ld r22, Z | |
| 153 | // AVR-NEXT: ldd r23, Z+1 | |
| 154 | // AVR-NEXT: adiw r24, 4 | |
| 155 | // AVR-NEXT: movw r30, r20 | |
| 156 | // AVR-NEXT: std Z+1, r25 | |
| 157 | // AVR-NEXT: st Z, r24 | |
| 158 | // AVR-NEXT: movw r30, r18 | |
| 159 | // AVR-NEXT: ldd r24, Z+2 | |
| 160 | // AVR-NEXT: ldd r25, Z+3 | |
| 161 | // AVR-NEXT: ret | |
| 162 | va_arg(ap) | |
| 163 | } | |
| 164 | ||
| 165 | #[unsafe(no_mangle)] | |
| 166 | unsafe extern "C" fn read_i64(ap: &mut VaList<'_>) -> i64 { | |
| 167 | // CHECK-LABEL: read_i64 | |
| 168 | // | |
| 169 | // AVR: push r14 | |
| 170 | // AVR-NEXT: push r15 | |
| 171 | // AVR-NEXT: push r16 | |
| 172 | // AVR-NEXT: push r17 | |
| 173 | // AVR-NEXT: movw r30, r24 | |
| 174 | // AVR-NEXT: ld r24, Z | |
| 175 | // AVR-NEXT: ldd r25, Z+1 | |
| 176 | // AVR-NEXT: movw r26, r24 | |
| 177 | // AVR-NEXT: adiw r26, 2 | |
| 178 | // AVR-NEXT: std Z+1, r27 | |
| 179 | // AVR-NEXT: st Z, r26 | |
| 180 | // AVR-NEXT: movw r14, r30 | |
| 181 | // AVR-NEXT: movw r16, r24 | |
| 182 | // AVR-NEXT: movw r30, r16 | |
| 183 | // AVR-NEXT: ld r18, Z | |
| 184 | // AVR-NEXT: ldd r19, Z+1 | |
| 185 | // AVR-NEXT: movw r26, r24 | |
| 186 | // AVR-NEXT: adiw r26, 4 | |
| 187 | // AVR-NEXT: movw r30, r14 | |
| 188 | // AVR-NEXT: std Z+1, r27 | |
| 189 | // AVR-NEXT: st Z, r26 | |
| 190 | // AVR-NEXT: movw r30, r16 | |
| 191 | // AVR-NEXT: ldd r20, Z+2 | |
| 192 | // AVR-NEXT: ldd r21, Z+3 | |
| 193 | // AVR-NEXT: movw r26, r24 | |
| 194 | // AVR-NEXT: adiw r26, 6 | |
| 195 | // AVR-NEXT: movw r30, r14 | |
| 196 | // AVR-NEXT: std Z+1, r27 | |
| 197 | // AVR-NEXT: st Z, r26 | |
| 198 | // AVR-NEXT: movw r30, r16 | |
| 199 | // AVR-NEXT: ldd r22, Z+4 | |
| 200 | // AVR-NEXT: ldd r23, Z+5 | |
| 201 | // AVR-NEXT: adiw r24, 8 | |
| 202 | // AVR-NEXT: movw r30, r14 | |
| 203 | // AVR-NEXT: std Z+1, r25 | |
| 204 | // AVR-NEXT: st Z, r24 | |
| 205 | // AVR-NEXT: movw r30, r16 | |
| 206 | // AVR-NEXT: ldd r24, Z+6 | |
| 207 | // AVR-NEXT: ldd r25, Z+7 | |
| 208 | // AVR-NEXT: pop r17 | |
| 209 | // AVR-NEXT: pop r16 | |
| 210 | // AVR-NEXT: pop r15 | |
| 211 | // AVR-NEXT: pop r14 | |
| 212 | // AVR-NEXT: ret | |
| 213 | va_arg(ap) | |
| 214 | } | |
| 215 | ||
| 216 | #[unsafe(no_mangle)] | |
| 217 | unsafe extern "C" fn read_ptr(ap: &mut VaList<'_>) -> *const u8 { | |
| 218 | // AVR: read_ptr = pm(read_i16) | |
| 219 | va_arg(ap) | |
| 220 | } |
tests/assembly-llvm/c-variadic/sparc.rs+1| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | //@ [SPARC64] compile-flags: -Copt-level=3 --target sparc64-unknown-linux-gnu |
| 8 | 8 | //@ [SPARC64] needs-llvm-components: sparc |
| 9 | 9 | #![feature(c_variadic, no_core, lang_items, intrinsics, rustc_attrs, asm_experimental_arch)] |
| 10 | #![cfg_attr(target_arch = "sparc", feature(c_variadic_experimental_arch))] | |
| 10 | 11 | #![no_core] |
| 11 | 12 | #![crate_type = "lib"] |
| 12 | 13 |
tests/rustdoc-html/doc-cfg/impl-foreign-type.rs created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | // This test ensures that the `doc_cfg` feature works on foreign types impl. | |
| 2 | // Regression test for <https://github.com/rust-lang/rust/issues/150268>. | |
| 3 | ||
| 4 | // ignore-tidy-linelength | |
| 5 | ||
| 6 | #![feature(doc_cfg)] | |
| 7 | #![crate_name = "foo"] | |
| 8 | ||
| 9 | //@has 'foo/trait.Blob.html' | |
| 10 | //@has - '//*[@id="impl-Blob-for-Box%3CR%3E"]//*[@class="stab portability"]' 'Available on non-crate feature alloc only.' | |
| 11 | ||
| 12 | pub trait Blob {} | |
| 13 | ||
| 14 | #[cfg(not(feature = "alloc"))] | |
| 15 | impl<R: ?Sized> Blob for std::boxed::Box<R> {} |
tests/ui/any/try_as_dyn_unsized.rs created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //@ run-pass | |
| 2 | #![feature(try_as_dyn)] | |
| 3 | ||
| 4 | use std::fmt::Debug; | |
| 5 | ||
| 6 | // Generic over `?Sized` T: relies on the relaxed bound on `try_as_dyn`. | |
| 7 | fn try_debug<T: ?Sized + 'static>(t: &T) -> Option<String> { | |
| 8 | std::any::try_as_dyn::<T, dyn Debug>(t).map(|d| format!("{d:?}")) | |
| 9 | } | |
| 10 | ||
| 11 | fn try_debug_mut<T: ?Sized + 'static>(t: &mut T) -> Option<String> { | |
| 12 | std::any::try_as_dyn_mut::<T, dyn Debug>(t).map(|d| format!("{d:?}")) | |
| 13 | } | |
| 14 | ||
| 15 | fn main() { | |
| 16 | // Sized case still works through a `?Sized` generic context. | |
| 17 | let x: i32 = 7; | |
| 18 | assert_eq!(try_debug(&x).as_deref(), Some("7")); | |
| 19 | ||
| 20 | let mut y: i32 = 8; | |
| 21 | assert_eq!(try_debug_mut(&mut y).as_deref(), Some("8")); | |
| 22 | ||
| 23 | // Unsized `T` always returns `None`, even though `str: Debug` and | |
| 24 | // `[T]: Debug` hold — vtable lookup for unsized impl types is not | |
| 25 | // currently supported by `TypeId::trait_info_of`. | |
| 26 | let s: &str = "hello"; | |
| 27 | assert!(try_debug::<str>(s).is_none()); | |
| 28 | ||
| 29 | let slice: &[i32] = &[1, 2, 3]; | |
| 30 | assert!(try_debug::<[i32]>(slice).is_none()); | |
| 31 | ||
| 32 | let dyn_any: &dyn std::any::Any = &0i32; | |
| 33 | assert!(try_debug::<dyn std::any::Any>(dyn_any).is_none()); | |
| 34 | } |
tests/ui/associated-types/ambiguous-associated-type-default.rs created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/23073 | |
| 2 | ||
| 3 | #![feature(associated_type_defaults)] | |
| 4 | ||
| 5 | trait Foo { type T; } | |
| 6 | trait Bar { | |
| 7 | type Foo: Foo; | |
| 8 | type FooT = <<Self as Bar>::Foo>::T; //~ ERROR ambiguous associated type | |
| 9 | } | |
| 10 | ||
| 11 | fn main() {} |
tests/ui/associated-types/ambiguous-associated-type-default.stderr created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | error[E0223]: ambiguous associated type | |
| 2 | --> $DIR/ambiguous-associated-type-default.rs:8:17 | |
| 3 | | | |
| 4 | LL | type FooT = <<Self as Bar>::Foo>::T; | |
| 5 | | ^^^^^^^^^^^^^^^^^^^^^^^ | |
| 6 | | | |
| 7 | help: if there were a trait named `Example` with associated type `T` implemented for `<Self as Bar>::Foo`, you could use the fully-qualified path | |
| 8 | | | |
| 9 | LL | type FooT = <<Self as Bar>::Foo as Example>::T; | |
| 10 | | ++++++++++ | |
| 11 | ||
| 12 | error: aborting due to 1 previous error | |
| 13 | ||
| 14 | For more information about this error, try `rustc --explain E0223`. |
tests/ui/associated-types/assoc-type-add-output-via-operator-syntax.rs created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/20803 | |
| 2 | ||
| 3 | //@ run-pass | |
| 4 | use std::ops::Add; | |
| 5 | ||
| 6 | fn foo<T>(x: T) -> <i32 as Add<T>>::Output where i32: Add<T> { | |
| 7 | 42i32 + x | |
| 8 | } | |
| 9 | ||
| 10 | fn main() { | |
| 11 | println!("{}", foo(0i32)); | |
| 12 | } |
tests/ui/associated-types/assoc-type-default-without-override-in-impl.rs created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/37051 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | ||
| 5 | #![feature(associated_type_defaults)] | |
| 6 | ||
| 7 | trait State: Sized { | |
| 8 | type NextState: State = StateMachineEnded; | |
| 9 | fn execute(self) -> Option<Self::NextState>; | |
| 10 | } | |
| 11 | ||
| 12 | struct StateMachineEnded; | |
| 13 | ||
| 14 | impl State for StateMachineEnded { | |
| 15 | fn execute(self) -> Option<Self::NextState> { | |
| 16 | None | |
| 17 | } | |
| 18 | } | |
| 19 | ||
| 20 | fn main() {} |
tests/ui/associated-types/assoc-type-element-mismatch-in-hrtb.rs created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/39970 | |
| 2 | ||
| 3 | trait Array<'a> { | |
| 4 | type Element: 'a; | |
| 5 | } | |
| 6 | ||
| 7 | trait Visit { | |
| 8 | fn visit() {} | |
| 9 | } | |
| 10 | ||
| 11 | impl<'a> Array<'a> for () { | |
| 12 | type Element = &'a (); | |
| 13 | } | |
| 14 | ||
| 15 | impl Visit for () where | |
| 16 | //(): for<'a> Array<'a, Element=&'a ()>, // No ICE | |
| 17 | (): for<'a> Array<'a, Element=()>, // ICE | |
| 18 | {} | |
| 19 | ||
| 20 | fn main() { | |
| 21 | <() as Visit>::visit(); | |
| 22 | //~^ ERROR type mismatch resolving `<() as Array<'a>>::Element == ()` | |
| 23 | } |
tests/ui/associated-types/assoc-type-element-mismatch-in-hrtb.stderr created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | error[E0271]: type mismatch resolving `<() as Array<'a>>::Element == ()` | |
| 2 | --> $DIR/assoc-type-element-mismatch-in-hrtb.rs:21:6 | |
| 3 | | | |
| 4 | LL | <() as Visit>::visit(); | |
| 5 | | ^^ type mismatch resolving `<() as Array<'a>>::Element == ()` | |
| 6 | | | |
| 7 | note: expected this to be `()` | |
| 8 | --> $DIR/assoc-type-element-mismatch-in-hrtb.rs:12:20 | |
| 9 | | | |
| 10 | LL | type Element = &'a (); | |
| 11 | | ^^^^^^ | |
| 12 | note: required for `()` to implement `Visit` | |
| 13 | --> $DIR/assoc-type-element-mismatch-in-hrtb.rs:15:6 | |
| 14 | | | |
| 15 | LL | impl Visit for () where | |
| 16 | | ^^^^^ ^^ | |
| 17 | LL | //(): for<'a> Array<'a, Element=&'a ()>, // No ICE | |
| 18 | LL | (): for<'a> Array<'a, Element=()>, // ICE | |
| 19 | | ---------- unsatisfied trait bound introduced here | |
| 20 | ||
| 21 | error: aborting due to 1 previous error | |
| 22 | ||
| 23 | For more information about this error, try `rustc --explain E0271`. |
tests/ui/associated-types/assoc-type-in-extern-fn-signature.rs created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/28983 | |
| 2 | ||
| 3 | //@ run-pass | |
| 4 | pub trait Test { type T; } | |
| 5 | ||
| 6 | impl Test for u32 { | |
| 7 | type T = i32; | |
| 8 | } | |
| 9 | ||
| 10 | pub mod export { | |
| 11 | #[no_mangle] | |
| 12 | pub extern "C" fn issue_28983(t: <u32 as crate::Test>::T) -> i32 { t*3 } | |
| 13 | } | |
| 14 | ||
| 15 | // to test both exporting and importing functions, import | |
| 16 | // a function from ourselves. | |
| 17 | extern "C" { | |
| 18 | fn issue_28983(t: <u32 as Test>::T) -> i32; | |
| 19 | } | |
| 20 | ||
| 21 | fn main() { | |
| 22 | assert_eq!(export::issue_28983(2), 6); | |
| 23 | assert_eq!(unsafe { issue_28983(3) }, 9); | |
| 24 | } |
tests/ui/associated-types/assoc-type-in-generic-struct-bound.rs created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/19632 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | #![allow(dead_code)] | |
| 5 | ||
| 6 | trait PoolManager { | |
| 7 | type C; | |
| 8 | fn dummy(&self) { } | |
| 9 | } | |
| 10 | ||
| 11 | struct InnerPool<M: PoolManager> { | |
| 12 | manager: M, | |
| 13 | } | |
| 14 | ||
| 15 | fn main() {} |
tests/ui/associated-types/assoc-type-in-strategy-pattern-iterator.rs created+93| ... | ... | @@ -0,0 +1,93 @@ |
| 1 | //@ build-pass | |
| 2 | ||
| 3 | // Regression test for https://github.com/rust-lang/rust/issues/20797 | |
| 4 | ||
| 5 | use std::default::Default; | |
| 6 | use std::io; | |
| 7 | use std::fs; | |
| 8 | use std::path::PathBuf; | |
| 9 | ||
| 10 | pub trait PathExtensions { | |
| 11 | fn is_dir(&self) -> bool { false } | |
| 12 | } | |
| 13 | ||
| 14 | impl PathExtensions for PathBuf {} | |
| 15 | ||
| 16 | /// A strategy for acquiring more subpaths to walk. | |
| 17 | pub trait Strategy { | |
| 18 | type P: PathExtensions; | |
| 19 | /// Gets additional subpaths from a given path. | |
| 20 | fn get_more(&self, item: &Self::P) -> io::Result<Vec<Self::P>>; | |
| 21 | /// Determine whether a path should be walked further. | |
| 22 | /// This is run against each item from `get_more()`. | |
| 23 | fn prune(&self, p: &Self::P) -> bool; | |
| 24 | } | |
| 25 | ||
| 26 | /// The basic fully-recursive strategy. Nothing is pruned. | |
| 27 | #[derive(Copy, Clone, Default)] | |
| 28 | pub struct Recursive; | |
| 29 | ||
| 30 | impl Strategy for Recursive { | |
| 31 | type P = PathBuf; | |
| 32 | fn get_more(&self, p: &PathBuf) -> io::Result<Vec<PathBuf>> { | |
| 33 | Ok(fs::read_dir(p).unwrap().map(|s| s.unwrap().path()).collect()) | |
| 34 | } | |
| 35 | ||
| 36 | fn prune(&self, _: &PathBuf) -> bool { false } | |
| 37 | } | |
| 38 | ||
| 39 | /// A directory walker of `P` using strategy `S`. | |
| 40 | pub struct Subpaths<S: Strategy> { | |
| 41 | stack: Vec<S::P>, | |
| 42 | strategy: S, | |
| 43 | } | |
| 44 | ||
| 45 | impl<S: Strategy> Subpaths<S> { | |
| 46 | /// Creates a directory walker with a root path and strategy. | |
| 47 | pub fn new(p: &S::P, strategy: S) -> io::Result<Subpaths<S>> { | |
| 48 | let stack = strategy.get_more(p)?; | |
| 49 | Ok(Subpaths { stack: stack, strategy: strategy }) | |
| 50 | } | |
| 51 | } | |
| 52 | ||
| 53 | impl<S: Default + Strategy> Subpaths<S> { | |
| 54 | /// Creates a directory walker with a root path and a default strategy. | |
| 55 | pub fn walk(p: &S::P) -> io::Result<Subpaths<S>> { | |
| 56 | Subpaths::new(p, Default::default()) | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | impl<S: Default + Strategy> Default for Subpaths<S> { | |
| 61 | fn default() -> Subpaths<S> { | |
| 62 | Subpaths { stack: Vec::new(), strategy: Default::default() } | |
| 63 | } | |
| 64 | } | |
| 65 | ||
| 66 | impl<S: Strategy> Iterator for Subpaths<S> { | |
| 67 | type Item = S::P; | |
| 68 | fn next (&mut self) -> Option<S::P> { | |
| 69 | let mut opt_path = self.stack.pop(); | |
| 70 | while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) { | |
| 71 | opt_path = self.stack.pop(); | |
| 72 | } | |
| 73 | match opt_path { | |
| 74 | Some(path) => { | |
| 75 | if path.is_dir() { | |
| 76 | let result = self.strategy.get_more(&path); | |
| 77 | match result { | |
| 78 | Ok(dirs) => { self.stack.extend(dirs); }, | |
| 79 | Err(..) => { } | |
| 80 | } | |
| 81 | } | |
| 82 | Some(path) | |
| 83 | } | |
| 84 | None => None, | |
| 85 | } | |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | fn _foo() { | |
| 90 | let _walker: Subpaths<Recursive> = Subpaths::walk(&PathBuf::from("/home")).unwrap(); | |
| 91 | } | |
| 92 | ||
| 93 | fn main() {} |
tests/ui/associated-types/assoc-type-in-struct-constructor.rs created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/26127 | |
| 2 | ||
| 3 | //@ run-pass | |
| 4 | trait Tr { type T; } | |
| 5 | impl Tr for u8 { type T=(); } | |
| 6 | struct S<I: Tr>(#[allow(dead_code)] I::T); | |
| 7 | ||
| 8 | fn foo<I: Tr>(i: I::T) { | |
| 9 | S::<I>(i); | |
| 10 | } | |
| 11 | ||
| 12 | fn main() { | |
| 13 | foo::<u8>(()); | |
| 14 | } |
tests/ui/associated-types/assoc-type-in-unused-where-clause.rs created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/19631 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | #![allow(dead_code)] | |
| 5 | ||
| 6 | trait PoolManager { | |
| 7 | type C; | |
| 8 | fn dummy(&self) { } | |
| 9 | } | |
| 10 | ||
| 11 | struct InnerPool<M> { | |
| 12 | manager: M, | |
| 13 | } | |
| 14 | ||
| 15 | impl<M> InnerPool<M> where M: PoolManager {} | |
| 16 | ||
| 17 | fn main() {} |
tests/ui/associated-types/assoc-type-layout-unsized-allowed-sized-used.rs created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //@ run-pass | |
| 2 | // Regression test for https://github.com/rust-lang/rust/issues/36036 | |
| 3 | // computing the layout of a type composed from another | |
| 4 | // trait's associated type caused compiler to ICE when the associated | |
| 5 | // type was allowed to be unsized, even though the known instantiated | |
| 6 | // type is itself sized. | |
| 7 | ||
| 8 | #![allow(dead_code)] | |
| 9 | ||
| 10 | trait Context { | |
| 11 | type Container: ?Sized; | |
| 12 | } | |
| 13 | ||
| 14 | impl Context for u16 { | |
| 15 | type Container = u8; | |
| 16 | } | |
| 17 | ||
| 18 | struct Wrapper<C: Context+'static> { | |
| 19 | container: &'static C::Container | |
| 20 | } | |
| 21 | ||
| 22 | fn foobar(_: Wrapper<u16>) {} | |
| 23 | ||
| 24 | static VALUE: u8 = 0; | |
| 25 | ||
| 26 | fn main() { | |
| 27 | foobar(Wrapper { container: &VALUE }); | |
| 28 | } |
tests/ui/associated-types/assoc-type-method-call-via-blanket-impl.rs created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/23336 | |
| 2 | ||
| 3 | //@ run-pass | |
| 4 | pub trait Data { fn doit(&self) {} } | |
| 5 | impl<T> Data for T {} | |
| 6 | pub trait UnaryLogic { type D: Data; } | |
| 7 | impl UnaryLogic for () { type D = i32; } | |
| 8 | ||
| 9 | pub fn crashes<T: UnaryLogic>(t: T::D) { | |
| 10 | t.doit(); | |
| 11 | } | |
| 12 | ||
| 13 | fn main() { crashes::<()>(0); } |
tests/ui/associated-types/assoc-type-named-string.rs created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/17732 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | #![allow(dead_code)] | |
| 5 | #![allow(non_camel_case_types)] | |
| 6 | ||
| 7 | trait Person { | |
| 8 | type string; | |
| 9 | fn dummy(&self) { } | |
| 10 | } | |
| 11 | ||
| 12 | struct Someone<P: Person>(std::marker::PhantomData<P>); | |
| 13 | ||
| 14 | fn main() {} |
tests/ui/associated-types/assoc-type-output-is-sized.rs created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/20009 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | // Check that associated types are `Sized` | |
| 5 | ||
| 6 | ||
| 7 | trait Trait { | |
| 8 | type Output; | |
| 9 | ||
| 10 | fn is_sized(&self) -> Self::Output; | |
| 11 | fn wasnt_sized(&self) -> Self::Output { loop {} } | |
| 12 | } | |
| 13 | ||
| 14 | fn main() {} |
tests/ui/associated-types/assoc-type-projection-in-box-return.rs created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | // Regression test for Issue https://github.com/rust-lang/rust/issues/20971 | |
| 2 | ||
| 3 | //@ run-fail | |
| 4 | //@ error-pattern:Hello, world! | |
| 5 | //@ needs-subprocess | |
| 6 | ||
| 7 | pub trait Parser { | |
| 8 | type Input; | |
| 9 | fn parse(&mut self, input: <Self as Parser>::Input); | |
| 10 | } | |
| 11 | ||
| 12 | impl Parser for () { | |
| 13 | type Input = (); | |
| 14 | fn parse(&mut self, input: ()) {} | |
| 15 | } | |
| 16 | ||
| 17 | pub fn many() -> Box<dyn Parser<Input = <() as Parser>::Input> + 'static> { | |
| 18 | panic!("Hello, world!") | |
| 19 | } | |
| 20 | ||
| 21 | fn main() { | |
| 22 | many().parse(()); | |
| 23 | } |
tests/ui/associated-types/assoc-type-projection-in-let-binding.rs created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/19850 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | #![allow(unused_variables)] | |
| 5 | // Test that `<Type as Trait>::Output` and `Self::Output` are accepted as type annotations in let | |
| 6 | // bindings | |
| 7 | ||
| 8 | ||
| 9 | trait Int { | |
| 10 | fn one() -> Self; | |
| 11 | fn leading_zeros(self) -> usize; | |
| 12 | } | |
| 13 | ||
| 14 | trait Foo { | |
| 15 | type T : Int; | |
| 16 | ||
| 17 | fn test(&self) { | |
| 18 | let r: <Self as Foo>::T = Int::one(); | |
| 19 | let r: Self::T = Int::one(); | |
| 20 | } | |
| 21 | } | |
| 22 | ||
| 23 | fn main() {} |
tests/ui/associated-types/assoc-type-projection-on-ref-lifetime.rs created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/23406 | |
| 2 | ||
| 3 | //@ build-pass | |
| 4 | #![allow(dead_code)] | |
| 5 | trait Inner { | |
| 6 | type T; | |
| 7 | } | |
| 8 | ||
| 9 | impl<'a> Inner for &'a i32 { | |
| 10 | type T = i32; | |
| 11 | } | |
| 12 | ||
| 13 | fn f<'a>(x: &'a i32) -> <&'a i32 as Inner>::T { | |
| 14 | *x | |
| 15 | } | |
| 16 | ||
| 17 | fn main() {} |
tests/ui/associated-types/assoc-type-ref-in-tuple-return.rs created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/37109 | |
| 2 | ||
| 3 | //@ run-pass | |
| 4 | trait ToRef<'a> { | |
| 5 | type Ref: 'a; | |
| 6 | } | |
| 7 | ||
| 8 | impl<'a, U: 'a> ToRef<'a> for U { | |
| 9 | type Ref = &'a U; | |
| 10 | } | |
| 11 | ||
| 12 | fn example<'a, T>(value: &'a T) -> (<T as ToRef<'a>>::Ref, u32) { | |
| 13 | (value, 0) | |
| 14 | } | |
| 15 | ||
| 16 | fn main() { | |
| 17 | example(&0); | |
| 18 | } |
tests/ui/associated-types/assoc-type-returns-outer-wrapping-self.rs created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/23992 | |
| 2 | ||
| 3 | //@ run-pass | |
| 4 | pub struct Outer<T: Trait>(T); | |
| 5 | pub struct Inner<'a> { value: &'a bool } | |
| 6 | ||
| 7 | pub trait Trait { | |
| 8 | type Error; | |
| 9 | fn ready(self) -> Self::Error; | |
| 10 | } | |
| 11 | ||
| 12 | impl<'a> Trait for Inner<'a> { | |
| 13 | type Error = Outer<Inner<'a>>; | |
| 14 | fn ready(self) -> Outer<Inner<'a>> { Outer(self) } | |
| 15 | } | |
| 16 | ||
| 17 | fn main() { | |
| 18 | let value = true; | |
| 19 | let inner = Inner { value: &value }; | |
| 20 | assert_eq!(inner.ready().0.value, &value); | |
| 21 | } |
tests/ui/associated-types/bound-references-sibling-assoc-type.rs created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/21909 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | ||
| 5 | trait A<X> { | |
| 6 | fn dummy(&self, arg: X); | |
| 7 | } | |
| 8 | ||
| 9 | trait B { | |
| 10 | type X; | |
| 11 | type Y: A<Self::X>; | |
| 12 | ||
| 13 | fn dummy(&self); | |
| 14 | } | |
| 15 | ||
| 16 | fn main () { } |
tests/ui/associated-types/enum-variant-with-assoc-type-and-lifetimes.rs created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/34839 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | ||
| 5 | trait RegularExpression: Sized { | |
| 6 | type Text; | |
| 7 | } | |
| 8 | ||
| 9 | struct ExecNoSyncStr<'a>(&'a u8); | |
| 10 | ||
| 11 | impl<'c> RegularExpression for ExecNoSyncStr<'c> { | |
| 12 | type Text = u8; | |
| 13 | } | |
| 14 | ||
| 15 | struct FindCaptures<'t, R>(&'t R::Text) where R: RegularExpression, R::Text: 't; | |
| 16 | ||
| 17 | enum FindCapturesInner<'r, 't> { | |
| 18 | Dynamic(FindCaptures<'t, ExecNoSyncStr<'r>>), | |
| 19 | } | |
| 20 | ||
| 21 | fn main() {} |
tests/ui/associated-types/method-on-impl-with-assoc-type-projection.rs created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | //@ run-pass | |
| 2 | trait Device { | |
| 3 | type Resources; | |
| 4 | } | |
| 5 | #[allow(dead_code)] | |
| 6 | struct Foo<D, R>(D, R); | |
| 7 | ||
| 8 | impl<D: Device> Foo<D, D::Resources> { | |
| 9 | fn present(&self) {} | |
| 10 | } | |
| 11 | ||
| 12 | struct Res; | |
| 13 | struct Dev; | |
| 14 | ||
| 15 | impl Device for Dev { type Resources = Res; } | |
| 16 | ||
| 17 | fn main() { | |
| 18 | let foo = Foo(Dev, Res); | |
| 19 | foo.present(); | |
| 20 | } |
tests/ui/associated-types/recursive-enum-with-assoc-type-selfref.rs created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | //@ run-pass | |
| 2 | #![allow(unused_variables)] | |
| 3 | pub trait Parameters { type SelfRef; } | |
| 4 | ||
| 5 | struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> } | |
| 6 | struct BP; | |
| 7 | ||
| 8 | impl<'a> Parameters for RP<'a> { type SelfRef = &'a X<RP<'a>>; } | |
| 9 | impl Parameters for BP { type SelfRef = Box<X<BP>>; } | |
| 10 | ||
| 11 | pub struct Y; | |
| 12 | pub enum X<P: Parameters> { | |
| 13 | Nothing, | |
| 14 | SameAgain(P::SelfRef, Y) | |
| 15 | } | |
| 16 | ||
| 17 | fn main() { | |
| 18 | let bnil: Box<X<BP>> = Box::new(X::Nothing); | |
| 19 | let bx: Box<X<BP>> = Box::new(X::SameAgain(bnil, Y)); | |
| 20 | let rnil: X<RP> = X::Nothing; | |
| 21 | let rx: X<RP> = X::SameAgain(&rnil, Y); | |
| 22 | } |
tests/ui/associated-types/same-name-assoc-type-and-method.rs created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/35600 | |
| 2 | ||
| 3 | //@ run-pass | |
| 4 | #![allow(non_camel_case_types)] | |
| 5 | #![allow(unused_variables)] | |
| 6 | ||
| 7 | trait Foo { | |
| 8 | type bar; | |
| 9 | fn bar(); | |
| 10 | } | |
| 11 | ||
| 12 | impl Foo for () { | |
| 13 | type bar = (); | |
| 14 | fn bar() {} | |
| 15 | } | |
| 16 | ||
| 17 | fn main() { | |
| 18 | let x: <() as Foo>::bar = (); | |
| 19 | <()>::bar(); | |
| 20 | } |
tests/ui/associated-types/self-type-alias-for-assoc-type.rs created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/27281 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | pub trait Trait<'a> { | |
| 5 | type T; | |
| 6 | type U; | |
| 7 | fn foo(&self, s: &'a ()) -> &'a (); | |
| 8 | } | |
| 9 | ||
| 10 | impl<'a> Trait<'a> for () { | |
| 11 | type T = &'a (); | |
| 12 | type U = Self::T; | |
| 13 | ||
| 14 | fn foo(&self, s: &'a ()) -> &'a () { | |
| 15 | let t: Self::T = s; t | |
| 16 | } | |
| 17 | } | |
| 18 | ||
| 19 | fn main() {} |
tests/ui/associated-types/simple-associated-type-impl.rs created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/18809 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | trait Tup { | |
| 5 | type T0; | |
| 6 | type T1; | |
| 7 | } | |
| 8 | ||
| 9 | impl Tup for isize { | |
| 10 | type T0 = f32; | |
| 11 | type T1 = (); | |
| 12 | } | |
| 13 | ||
| 14 | fn main() {} |
tests/ui/associated-types/size-of-assoc-type-output.rs created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | //! Regression test for https://github.com/rust-lang/rust/issues/43357 | |
| 2 | ||
| 3 | //@ check-pass | |
| 4 | #![allow(dead_code)] | |
| 5 | trait Trait { | |
| 6 | type Output; | |
| 7 | } | |
| 8 | ||
| 9 | fn f<T: Trait>() { | |
| 10 | std::mem::size_of::<T::Output>(); | |
| 11 | } | |
| 12 | ||
| 13 | fn main() {} |
tests/ui/associated-types/unspecified-assoc-type-in-trait-object.rs created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | // Regression test for https://github.com/rust-lang/rust/issues/19842 | |
| 2 | // Test that a partially specified trait object with unspecified associated | |
| 3 | // type does not type-check. | |
| 4 | ||
| 5 | trait Foo { | |
| 6 | type A; | |
| 7 | ||
| 8 | fn dummy(&self) { } | |
| 9 | } | |
| 10 | ||
| 11 | fn bar(x: &dyn Foo) {} | |
| 12 | //~^ ERROR the associated type `A` in `Foo` must be specified | |
| 13 | ||
| 14 | pub fn main() {} |
tests/ui/associated-types/unspecified-assoc-type-in-trait-object.stderr created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | error[E0191]: the value of the associated type `A` in `Foo` must be specified | |
| 2 | --> $DIR/unspecified-assoc-type-in-trait-object.rs:11:16 | |
| 3 | | | |
| 4 | LL | type A; | |
| 5 | | ------ `A` defined here | |
| 6 | ... | |
| 7 | LL | fn bar(x: &dyn Foo) {} | |
| 8 | | ^^^ | |
| 9 | | | |
| 10 | help: specify the associated type | |
| 11 | | | |
| 12 | LL | fn bar(x: &dyn Foo<A = /* Type */>) {} | |
| 13 | | ++++++++++++++++ | |
| 14 | ||
| 15 | error: aborting due to 1 previous error | |
| 16 | ||
| 17 | For more information about this error, try `rustc --explain E0191`. |
tests/ui/drop/explicit-drop-call-error.fixed+1-1| ... | ... | @@ -11,5 +11,5 @@ impl Drop for Foo { |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | fn main() { |
| 14 | drop(&mut Foo) //~ ERROR explicit use of destructor method | |
| 14 | drop(Foo) //~ ERROR explicit use of destructor method | |
| 15 | 15 | } |
tests/ui/drop/explicit-drop-call-error.stderr+7-4| ... | ... | @@ -2,10 +2,13 @@ error[E0040]: explicit use of destructor method |
| 2 | 2 | --> $DIR/explicit-drop-call-error.rs:14:5 |
| 3 | 3 | | |
| 4 | 4 | LL | Drop::drop(&mut Foo) |
| 5 | | ^^^^^^^^^^ | |
| 6 | | | | |
| 7 | | explicit destructor calls not allowed | |
| 8 | | help: consider using `drop` function: `drop` | |
| 5 | | ^^^^^^^^^^ explicit destructor calls not allowed | |
| 6 | | | |
| 7 | help: consider using `drop` function | |
| 8 | | | |
| 9 | LL - Drop::drop(&mut Foo) | |
| 10 | LL + drop(Foo) | |
| 11 | | | |
| 9 | 12 | |
| 10 | 13 | error: aborting due to 1 previous error |
| 11 | 14 |
tests/ui/drop/explicit-drop-call-named-ref.fixed created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | //@ run-rustfix | |
| 2 | ||
| 3 | struct Foo; | |
| 4 | ||
| 5 | impl Drop for Foo { | |
| 6 | fn drop(&mut self) {} | |
| 7 | } | |
| 8 | ||
| 9 | fn foo(f: Foo) { | |
| 10 | drop(f); //~ ERROR explicit use of destructor method | |
| 11 | //~| HELP: consider using `drop` function | |
| 12 | } | |
| 13 | ||
| 14 | fn main() { | |
| 15 | let f = Foo; | |
| 16 | foo(f); | |
| 17 | } |
tests/ui/drop/explicit-drop-call-named-ref.rs created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | //@ run-rustfix | |
| 2 | ||
| 3 | struct Foo; | |
| 4 | ||
| 5 | impl Drop for Foo { | |
| 6 | fn drop(&mut self) {} | |
| 7 | } | |
| 8 | ||
| 9 | fn foo(f: Foo) { | |
| 10 | Drop::drop(&mut f); //~ ERROR explicit use of destructor method | |
| 11 | //~| HELP: consider using `drop` function | |
| 12 | } | |
| 13 | ||
| 14 | fn main() { | |
| 15 | let f = Foo; | |
| 16 | foo(f); | |
| 17 | } |
tests/ui/drop/explicit-drop-call-named-ref.stderr created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | error[E0040]: explicit use of destructor method | |
| 2 | --> $DIR/explicit-drop-call-named-ref.rs:10:5 | |
| 3 | | | |
| 4 | LL | Drop::drop(&mut f); | |
| 5 | | ^^^^^^^^^^ explicit destructor calls not allowed | |
| 6 | | | |
| 7 | help: consider using `drop` function | |
| 8 | | | |
| 9 | LL - Drop::drop(&mut f); | |
| 10 | LL + drop(f); | |
| 11 | | | |
| 12 | ||
| 13 | error: aborting due to 1 previous error | |
| 14 | ||
| 15 | For more information about this error, try `rustc --explain E0040`. |
tests/ui/imports/extern-crate-self/extern-crate-self-macro-item.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | |
| 3 | 3 | // Test that `extern crate self;` is accepted |
| 4 | 4 | // syntactically as an item for use in a macro. |
tests/ui/imports/extern-crate-self/extern-crate-self-pass.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | |
| 3 | 3 | extern crate self as foo; |
| 4 | 4 |
tests/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | //@ edition:2018 |
| 3 | 3 | |
| 4 | 4 | macro_rules! define_iso { () => { |
tests/ui/imports/extern-prelude-extern-crate-cfg.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | //@ compile-flags:--cfg my_feature --check-cfg=cfg(my_feature) |
| 3 | 3 | |
| 4 | 4 | #![no_std] |
tests/ui/imports/extern-prelude-extern-crate-pass.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | //@ aux-build:two_macros.rs |
| 3 | 3 | |
| 4 | 4 | extern crate two_macros; |
tests/ui/imports/extern-prelude-extern-crate-shadowing.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | //@ aux-build:two_macros.rs |
| 3 | 3 | |
| 4 | 4 | extern crate two_macros as core; |
tests/ui/imports/local-modularized-tricky-pass-1.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | |
| 3 | 3 | macro_rules! define_exported { () => { |
| 4 | 4 | #[macro_export] |
tests/ui/imports/local-modularized.rs+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | //@ edition:2015 |
| 2 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 2 | //@ check-pass | |
| 3 | 3 | |
| 4 | 4 | #[macro_export(local_inner_macros)] |
| 5 | 5 | macro_rules! dollar_crate_exported { |
tests/ui/issues/issue-17732.rs deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | #![allow(dead_code)] | |
| 3 | #![allow(non_camel_case_types)] | |
| 4 | ||
| 5 | trait Person { | |
| 6 | type string; | |
| 7 | fn dummy(&self) { } | |
| 8 | } | |
| 9 | ||
| 10 | struct Someone<P: Person>(std::marker::PhantomData<P>); | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/issues/issue-18809.rs deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | trait Tup { | |
| 3 | type T0; | |
| 4 | type T1; | |
| 5 | } | |
| 6 | ||
| 7 | impl Tup for isize { | |
| 8 | type T0 = f32; | |
| 9 | type T1 = (); | |
| 10 | } | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/issues/issue-19482.rs deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | // Test that a partially specified trait object with unspecified associated | |
| 2 | // type does not type-check. | |
| 3 | ||
| 4 | trait Foo { | |
| 5 | type A; | |
| 6 | ||
| 7 | fn dummy(&self) { } | |
| 8 | } | |
| 9 | ||
| 10 | fn bar(x: &dyn Foo) {} | |
| 11 | //~^ ERROR the associated type `A` in `Foo` must be specified | |
| 12 | ||
| 13 | pub fn main() {} |
tests/ui/issues/issue-19482.stderr deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | error[E0191]: the value of the associated type `A` in `Foo` must be specified | |
| 2 | --> $DIR/issue-19482.rs:10:16 | |
| 3 | | | |
| 4 | LL | type A; | |
| 5 | | ------ `A` defined here | |
| 6 | ... | |
| 7 | LL | fn bar(x: &dyn Foo) {} | |
| 8 | | ^^^ | |
| 9 | | | |
| 10 | help: specify the associated type | |
| 11 | | | |
| 12 | LL | fn bar(x: &dyn Foo<A = /* Type */>) {} | |
| 13 | | ++++++++++++++++ | |
| 14 | ||
| 15 | error: aborting due to 1 previous error | |
| 16 | ||
| 17 | For more information about this error, try `rustc --explain E0191`. |
tests/ui/issues/issue-19631.rs deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | #![allow(dead_code)] | |
| 3 | ||
| 4 | trait PoolManager { | |
| 5 | type C; | |
| 6 | fn dummy(&self) { } | |
| 7 | } | |
| 8 | ||
| 9 | struct InnerPool<M> { | |
| 10 | manager: M, | |
| 11 | } | |
| 12 | ||
| 13 | impl<M> InnerPool<M> where M: PoolManager {} | |
| 14 | ||
| 15 | fn main() {} |
tests/ui/issues/issue-19632.rs deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | #![allow(dead_code)] | |
| 3 | ||
| 4 | trait PoolManager { | |
| 5 | type C; | |
| 6 | fn dummy(&self) { } | |
| 7 | } | |
| 8 | ||
| 9 | struct InnerPool<M: PoolManager> { | |
| 10 | manager: M, | |
| 11 | } | |
| 12 | ||
| 13 | fn main() {} |
tests/ui/issues/issue-19850.rs deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | #![allow(unused_variables)] | |
| 3 | // Test that `<Type as Trait>::Output` and `Self::Output` are accepted as type annotations in let | |
| 4 | // bindings | |
| 5 | ||
| 6 | ||
| 7 | trait Int { | |
| 8 | fn one() -> Self; | |
| 9 | fn leading_zeros(self) -> usize; | |
| 10 | } | |
| 11 | ||
| 12 | trait Foo { | |
| 13 | type T : Int; | |
| 14 | ||
| 15 | fn test(&self) { | |
| 16 | let r: <Self as Foo>::T = Int::one(); | |
| 17 | let r: Self::T = Int::one(); | |
| 18 | } | |
| 19 | } | |
| 20 | ||
| 21 | fn main() {} |
tests/ui/issues/issue-20009.rs deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | // Check that associated types are `Sized` | |
| 3 | ||
| 4 | ||
| 5 | trait Trait { | |
| 6 | type Output; | |
| 7 | ||
| 8 | fn is_sized(&self) -> Self::Output; | |
| 9 | fn wasnt_sized(&self) -> Self::Output { loop {} } | |
| 10 | } | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/issues/issue-20797.rs deleted-93| ... | ... | @@ -1,93 +0,0 @@ |
| 1 | //@ build-pass | |
| 2 | ||
| 3 | // Regression test for #20797. | |
| 4 | ||
| 5 | use std::default::Default; | |
| 6 | use std::io; | |
| 7 | use std::fs; | |
| 8 | use std::path::PathBuf; | |
| 9 | ||
| 10 | pub trait PathExtensions { | |
| 11 | fn is_dir(&self) -> bool { false } | |
| 12 | } | |
| 13 | ||
| 14 | impl PathExtensions for PathBuf {} | |
| 15 | ||
| 16 | /// A strategy for acquiring more subpaths to walk. | |
| 17 | pub trait Strategy { | |
| 18 | type P: PathExtensions; | |
| 19 | /// Gets additional subpaths from a given path. | |
| 20 | fn get_more(&self, item: &Self::P) -> io::Result<Vec<Self::P>>; | |
| 21 | /// Determine whether a path should be walked further. | |
| 22 | /// This is run against each item from `get_more()`. | |
| 23 | fn prune(&self, p: &Self::P) -> bool; | |
| 24 | } | |
| 25 | ||
| 26 | /// The basic fully-recursive strategy. Nothing is pruned. | |
| 27 | #[derive(Copy, Clone, Default)] | |
| 28 | pub struct Recursive; | |
| 29 | ||
| 30 | impl Strategy for Recursive { | |
| 31 | type P = PathBuf; | |
| 32 | fn get_more(&self, p: &PathBuf) -> io::Result<Vec<PathBuf>> { | |
| 33 | Ok(fs::read_dir(p).unwrap().map(|s| s.unwrap().path()).collect()) | |
| 34 | } | |
| 35 | ||
| 36 | fn prune(&self, _: &PathBuf) -> bool { false } | |
| 37 | } | |
| 38 | ||
| 39 | /// A directory walker of `P` using strategy `S`. | |
| 40 | pub struct Subpaths<S: Strategy> { | |
| 41 | stack: Vec<S::P>, | |
| 42 | strategy: S, | |
| 43 | } | |
| 44 | ||
| 45 | impl<S: Strategy> Subpaths<S> { | |
| 46 | /// Creates a directory walker with a root path and strategy. | |
| 47 | pub fn new(p: &S::P, strategy: S) -> io::Result<Subpaths<S>> { | |
| 48 | let stack = strategy.get_more(p)?; | |
| 49 | Ok(Subpaths { stack: stack, strategy: strategy }) | |
| 50 | } | |
| 51 | } | |
| 52 | ||
| 53 | impl<S: Default + Strategy> Subpaths<S> { | |
| 54 | /// Creates a directory walker with a root path and a default strategy. | |
| 55 | pub fn walk(p: &S::P) -> io::Result<Subpaths<S>> { | |
| 56 | Subpaths::new(p, Default::default()) | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | impl<S: Default + Strategy> Default for Subpaths<S> { | |
| 61 | fn default() -> Subpaths<S> { | |
| 62 | Subpaths { stack: Vec::new(), strategy: Default::default() } | |
| 63 | } | |
| 64 | } | |
| 65 | ||
| 66 | impl<S: Strategy> Iterator for Subpaths<S> { | |
| 67 | type Item = S::P; | |
| 68 | fn next (&mut self) -> Option<S::P> { | |
| 69 | let mut opt_path = self.stack.pop(); | |
| 70 | while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) { | |
| 71 | opt_path = self.stack.pop(); | |
| 72 | } | |
| 73 | match opt_path { | |
| 74 | Some(path) => { | |
| 75 | if path.is_dir() { | |
| 76 | let result = self.strategy.get_more(&path); | |
| 77 | match result { | |
| 78 | Ok(dirs) => { self.stack.extend(dirs); }, | |
| 79 | Err(..) => { } | |
| 80 | } | |
| 81 | } | |
| 82 | Some(path) | |
| 83 | } | |
| 84 | None => None, | |
| 85 | } | |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | fn _foo() { | |
| 90 | let _walker: Subpaths<Recursive> = Subpaths::walk(&PathBuf::from("/home")).unwrap(); | |
| 91 | } | |
| 92 | ||
| 93 | fn main() {} |
tests/ui/issues/issue-20803.rs deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | use std::ops::Add; | |
| 3 | ||
| 4 | fn foo<T>(x: T) -> <i32 as Add<T>>::Output where i32: Add<T> { | |
| 5 | 42i32 + x | |
| 6 | } | |
| 7 | ||
| 8 | fn main() { | |
| 9 | println!("{}", foo(0i32)); | |
| 10 | } |
tests/ui/issues/issue-20971.rs deleted-23| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | // Regression test for Issue #20971. | |
| 2 | ||
| 3 | //@ run-fail | |
| 4 | //@ error-pattern:Hello, world! | |
| 5 | //@ needs-subprocess | |
| 6 | ||
| 7 | pub trait Parser { | |
| 8 | type Input; | |
| 9 | fn parse(&mut self, input: <Self as Parser>::Input); | |
| 10 | } | |
| 11 | ||
| 12 | impl Parser for () { | |
| 13 | type Input = (); | |
| 14 | fn parse(&mut self, input: ()) {} | |
| 15 | } | |
| 16 | ||
| 17 | pub fn many() -> Box<dyn Parser<Input = <() as Parser>::Input> + 'static> { | |
| 18 | panic!("Hello, world!") | |
| 19 | } | |
| 20 | ||
| 21 | fn main() { | |
| 22 | many().parse(()); | |
| 23 | } |
tests/ui/issues/issue-21909.rs deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | ||
| 3 | trait A<X> { | |
| 4 | fn dummy(&self, arg: X); | |
| 5 | } | |
| 6 | ||
| 7 | trait B { | |
| 8 | type X; | |
| 9 | type Y: A<Self::X>; | |
| 10 | ||
| 11 | fn dummy(&self); | |
| 12 | } | |
| 13 | ||
| 14 | fn main () { } |
tests/ui/issues/issue-23073.rs deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | #![feature(associated_type_defaults)] | |
| 2 | ||
| 3 | trait Foo { type T; } | |
| 4 | trait Bar { | |
| 5 | type Foo: Foo; | |
| 6 | type FooT = <<Self as Bar>::Foo>::T; //~ ERROR ambiguous associated type | |
| 7 | } | |
| 8 | ||
| 9 | fn main() {} |
tests/ui/issues/issue-23073.stderr deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | error[E0223]: ambiguous associated type | |
| 2 | --> $DIR/issue-23073.rs:6:17 | |
| 3 | | | |
| 4 | LL | type FooT = <<Self as Bar>::Foo>::T; | |
| 5 | | ^^^^^^^^^^^^^^^^^^^^^^^ | |
| 6 | | | |
| 7 | help: if there were a trait named `Example` with associated type `T` implemented for `<Self as Bar>::Foo`, you could use the fully-qualified path | |
| 8 | | | |
| 9 | LL | type FooT = <<Self as Bar>::Foo as Example>::T; | |
| 10 | | ++++++++++ | |
| 11 | ||
| 12 | error: aborting due to 1 previous error | |
| 13 | ||
| 14 | For more information about this error, try `rustc --explain E0223`. |
tests/ui/issues/issue-23336.rs deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | pub trait Data { fn doit(&self) {} } | |
| 3 | impl<T> Data for T {} | |
| 4 | pub trait UnaryLogic { type D: Data; } | |
| 5 | impl UnaryLogic for () { type D = i32; } | |
| 6 | ||
| 7 | pub fn crashes<T: UnaryLogic>(t: T::D) { | |
| 8 | t.doit(); | |
| 9 | } | |
| 10 | ||
| 11 | fn main() { crashes::<()>(0); } |
tests/ui/issues/issue-23406.rs deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | //@ build-pass | |
| 2 | #![allow(dead_code)] | |
| 3 | trait Inner { | |
| 4 | type T; | |
| 5 | } | |
| 6 | ||
| 7 | impl<'a> Inner for &'a i32 { | |
| 8 | type T = i32; | |
| 9 | } | |
| 10 | ||
| 11 | fn f<'a>(x: &'a i32) -> <&'a i32 as Inner>::T { | |
| 12 | *x | |
| 13 | } | |
| 14 | ||
| 15 | fn main() {} |
tests/ui/issues/issue-23992.rs deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | pub struct Outer<T: Trait>(T); | |
| 3 | pub struct Inner<'a> { value: &'a bool } | |
| 4 | ||
| 5 | pub trait Trait { | |
| 6 | type Error; | |
| 7 | fn ready(self) -> Self::Error; | |
| 8 | } | |
| 9 | ||
| 10 | impl<'a> Trait for Inner<'a> { | |
| 11 | type Error = Outer<Inner<'a>>; | |
| 12 | fn ready(self) -> Outer<Inner<'a>> { Outer(self) } | |
| 13 | } | |
| 14 | ||
| 15 | fn main() { | |
| 16 | let value = true; | |
| 17 | let inner = Inner { value: &value }; | |
| 18 | assert_eq!(inner.ready().0.value, &value); | |
| 19 | } |
tests/ui/issues/issue-25679.rs deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | trait Device { | |
| 3 | type Resources; | |
| 4 | } | |
| 5 | #[allow(dead_code)] | |
| 6 | struct Foo<D, R>(D, R); | |
| 7 | ||
| 8 | impl<D: Device> Foo<D, D::Resources> { | |
| 9 | fn present(&self) {} | |
| 10 | } | |
| 11 | ||
| 12 | struct Res; | |
| 13 | struct Dev; | |
| 14 | ||
| 15 | impl Device for Dev { type Resources = Res; } | |
| 16 | ||
| 17 | fn main() { | |
| 18 | let foo = Foo(Dev, Res); | |
| 19 | foo.present(); | |
| 20 | } |
tests/ui/issues/issue-25693.rs deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | #![allow(unused_variables)] | |
| 3 | pub trait Parameters { type SelfRef; } | |
| 4 | ||
| 5 | struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> } | |
| 6 | struct BP; | |
| 7 | ||
| 8 | impl<'a> Parameters for RP<'a> { type SelfRef = &'a X<RP<'a>>; } | |
| 9 | impl Parameters for BP { type SelfRef = Box<X<BP>>; } | |
| 10 | ||
| 11 | pub struct Y; | |
| 12 | pub enum X<P: Parameters> { | |
| 13 | Nothing, | |
| 14 | SameAgain(P::SelfRef, Y) | |
| 15 | } | |
| 16 | ||
| 17 | fn main() { | |
| 18 | let bnil: Box<X<BP>> = Box::new(X::Nothing); | |
| 19 | let bx: Box<X<BP>> = Box::new(X::SameAgain(bnil, Y)); | |
| 20 | let rnil: X<RP> = X::Nothing; | |
| 21 | let rx: X<RP> = X::SameAgain(&rnil, Y); | |
| 22 | } |
tests/ui/issues/issue-26127.rs deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | trait Tr { type T; } | |
| 3 | impl Tr for u8 { type T=(); } | |
| 4 | struct S<I: Tr>(#[allow(dead_code)] I::T); | |
| 5 | ||
| 6 | fn foo<I: Tr>(i: I::T) { | |
| 7 | S::<I>(i); | |
| 8 | } | |
| 9 | ||
| 10 | fn main() { | |
| 11 | foo::<u8>(()); | |
| 12 | } |
tests/ui/issues/issue-27281.rs deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | pub trait Trait<'a> { | |
| 3 | type T; | |
| 4 | type U; | |
| 5 | fn foo(&self, s: &'a ()) -> &'a (); | |
| 6 | } | |
| 7 | ||
| 8 | impl<'a> Trait<'a> for () { | |
| 9 | type T = &'a (); | |
| 10 | type U = Self::T; | |
| 11 | ||
| 12 | fn foo(&self, s: &'a ()) -> &'a () { | |
| 13 | let t: Self::T = s; t | |
| 14 | } | |
| 15 | } | |
| 16 | ||
| 17 | fn main() {} |
tests/ui/issues/issue-28983.rs deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | pub trait Test { type T; } | |
| 3 | ||
| 4 | impl Test for u32 { | |
| 5 | type T = i32; | |
| 6 | } | |
| 7 | ||
| 8 | pub mod export { | |
| 9 | #[no_mangle] | |
| 10 | pub extern "C" fn issue_28983(t: <u32 as crate::Test>::T) -> i32 { t*3 } | |
| 11 | } | |
| 12 | ||
| 13 | // to test both exporting and importing functions, import | |
| 14 | // a function from ourselves. | |
| 15 | extern "C" { | |
| 16 | fn issue_28983(t: <u32 as Test>::T) -> i32; | |
| 17 | } | |
| 18 | ||
| 19 | fn main() { | |
| 20 | assert_eq!(export::issue_28983(2), 6); | |
| 21 | assert_eq!(unsafe { issue_28983(3) }, 9); | |
| 22 | } |
tests/ui/issues/issue-34839.rs deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | ||
| 3 | trait RegularExpression: Sized { | |
| 4 | type Text; | |
| 5 | } | |
| 6 | ||
| 7 | struct ExecNoSyncStr<'a>(&'a u8); | |
| 8 | ||
| 9 | impl<'c> RegularExpression for ExecNoSyncStr<'c> { | |
| 10 | type Text = u8; | |
| 11 | } | |
| 12 | ||
| 13 | struct FindCaptures<'t, R>(&'t R::Text) where R: RegularExpression, R::Text: 't; | |
| 14 | ||
| 15 | enum FindCapturesInner<'r, 't> { | |
| 16 | Dynamic(FindCaptures<'t, ExecNoSyncStr<'r>>), | |
| 17 | } | |
| 18 | ||
| 19 | fn main() {} |
tests/ui/issues/issue-35600.rs deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | #![allow(non_camel_case_types)] | |
| 3 | #![allow(unused_variables)] | |
| 4 | ||
| 5 | trait Foo { | |
| 6 | type bar; | |
| 7 | fn bar(); | |
| 8 | } | |
| 9 | ||
| 10 | impl Foo for () { | |
| 11 | type bar = (); | |
| 12 | fn bar() {} | |
| 13 | } | |
| 14 | ||
| 15 | fn main() { | |
| 16 | let x: <() as Foo>::bar = (); | |
| 17 | <()>::bar(); | |
| 18 | } |
tests/ui/issues/issue-36036-associated-type-layout.rs deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | // Issue 36036: computing the layout of a type composed from another | |
| 3 | // trait's associated type caused compiler to ICE when the associated | |
| 4 | // type was allowed to be unsized, even though the known instantiated | |
| 5 | // type is itself sized. | |
| 6 | ||
| 7 | #![allow(dead_code)] | |
| 8 | ||
| 9 | trait Context { | |
| 10 | type Container: ?Sized; | |
| 11 | } | |
| 12 | ||
| 13 | impl Context for u16 { | |
| 14 | type Container = u8; | |
| 15 | } | |
| 16 | ||
| 17 | struct Wrapper<C: Context+'static> { | |
| 18 | container: &'static C::Container | |
| 19 | } | |
| 20 | ||
| 21 | fn foobar(_: Wrapper<u16>) {} | |
| 22 | ||
| 23 | static VALUE: u8 = 0; | |
| 24 | ||
| 25 | fn main() { | |
| 26 | foobar(Wrapper { container: &VALUE }); | |
| 27 | } |
tests/ui/issues/issue-37051.rs deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | ||
| 3 | #![feature(associated_type_defaults)] | |
| 4 | ||
| 5 | trait State: Sized { | |
| 6 | type NextState: State = StateMachineEnded; | |
| 7 | fn execute(self) -> Option<Self::NextState>; | |
| 8 | } | |
| 9 | ||
| 10 | struct StateMachineEnded; | |
| 11 | ||
| 12 | impl State for StateMachineEnded { | |
| 13 | fn execute(self) -> Option<Self::NextState> { | |
| 14 | None | |
| 15 | } | |
| 16 | } | |
| 17 | ||
| 18 | fn main() {} |
tests/ui/issues/issue-37109.rs deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | //@ run-pass | |
| 2 | trait ToRef<'a> { | |
| 3 | type Ref: 'a; | |
| 4 | } | |
| 5 | ||
| 6 | impl<'a, U: 'a> ToRef<'a> for U { | |
| 7 | type Ref = &'a U; | |
| 8 | } | |
| 9 | ||
| 10 | fn example<'a, T>(value: &'a T) -> (<T as ToRef<'a>>::Ref, u32) { | |
| 11 | (value, 0) | |
| 12 | } | |
| 13 | ||
| 14 | fn main() { | |
| 15 | example(&0); | |
| 16 | } |
tests/ui/issues/issue-39970.rs deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | trait Array<'a> { | |
| 2 | type Element: 'a; | |
| 3 | } | |
| 4 | ||
| 5 | trait Visit { | |
| 6 | fn visit() {} | |
| 7 | } | |
| 8 | ||
| 9 | impl<'a> Array<'a> for () { | |
| 10 | type Element = &'a (); | |
| 11 | } | |
| 12 | ||
| 13 | impl Visit for () where | |
| 14 | //(): for<'a> Array<'a, Element=&'a ()>, // No ICE | |
| 15 | (): for<'a> Array<'a, Element=()>, // ICE | |
| 16 | {} | |
| 17 | ||
| 18 | fn main() { | |
| 19 | <() as Visit>::visit(); | |
| 20 | //~^ ERROR type mismatch resolving `<() as Array<'a>>::Element == ()` | |
| 21 | } |
tests/ui/issues/issue-39970.stderr deleted-23| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | error[E0271]: type mismatch resolving `<() as Array<'a>>::Element == ()` | |
| 2 | --> $DIR/issue-39970.rs:19:6 | |
| 3 | | | |
| 4 | LL | <() as Visit>::visit(); | |
| 5 | | ^^ type mismatch resolving `<() as Array<'a>>::Element == ()` | |
| 6 | | | |
| 7 | note: expected this to be `()` | |
| 8 | --> $DIR/issue-39970.rs:10:20 | |
| 9 | | | |
| 10 | LL | type Element = &'a (); | |
| 11 | | ^^^^^^ | |
| 12 | note: required for `()` to implement `Visit` | |
| 13 | --> $DIR/issue-39970.rs:13:6 | |
| 14 | | | |
| 15 | LL | impl Visit for () where | |
| 16 | | ^^^^^ ^^ | |
| 17 | LL | //(): for<'a> Array<'a, Element=&'a ()>, // No ICE | |
| 18 | LL | (): for<'a> Array<'a, Element=()>, // ICE | |
| 19 | | ---------- unsatisfied trait bound introduced here | |
| 20 | ||
| 21 | error: aborting due to 1 previous error | |
| 22 | ||
| 23 | For more information about this error, try `rustc --explain E0271`. |
tests/ui/issues/issue-43357.rs deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | //@ check-pass | |
| 2 | #![allow(dead_code)] | |
| 3 | trait Trait { | |
| 4 | type Output; | |
| 5 | } | |
| 6 | ||
| 7 | fn f<T: Trait>() { | |
| 8 | std::mem::size_of::<T::Output>(); | |
| 9 | } | |
| 10 | ||
| 11 | fn main() {} |
tests/ui/pin-ergonomics/ref-pat-suggestions.fixed created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | //@ run-rustfix | |
| 2 | ||
| 3 | #![feature(pin_ergonomics)] | |
| 4 | #![allow(unused)] | |
| 5 | ||
| 6 | fn pin_mut_param(x: &pin mut i32) {} | |
| 7 | //~^ ERROR mismatched types | |
| 8 | ||
| 9 | fn pin_const_param(x: &pin const i32) {} | |
| 10 | //~^ ERROR mismatched types | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/pin-ergonomics/ref-pat-suggestions.rs created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | //@ run-rustfix | |
| 2 | ||
| 3 | #![feature(pin_ergonomics)] | |
| 4 | #![allow(unused)] | |
| 5 | ||
| 6 | fn pin_mut_param(&pin mut x: i32) {} | |
| 7 | //~^ ERROR mismatched types | |
| 8 | ||
| 9 | fn pin_const_param(&pin const x: i32) {} | |
| 10 | //~^ ERROR mismatched types | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/pin-ergonomics/ref-pat-suggestions.stderr created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | error[E0308]: mismatched types | |
| 2 | --> $DIR/ref-pat-suggestions.rs:6:18 | |
| 3 | | | |
| 4 | LL | fn pin_mut_param(&pin mut x: i32) {} | |
| 5 | | ^^^^^^^^^^ --- expected due to this | |
| 6 | | | | |
| 7 | | expected `i32`, found `Pin<&mut _>` | |
| 8 | | | |
| 9 | = note: expected type `i32` | |
| 10 | found struct `Pin<&mut _>` | |
| 11 | note: to declare a mutable parameter use: `mut x` | |
| 12 | --> $DIR/ref-pat-suggestions.rs:6:18 | |
| 13 | | | |
| 14 | LL | fn pin_mut_param(&pin mut x: i32) {} | |
| 15 | | ^^^^^^^^^^ | |
| 16 | help: to take parameter `x` by reference, move `&pin mut` to the type | |
| 17 | | | |
| 18 | LL - fn pin_mut_param(&pin mut x: i32) {} | |
| 19 | LL + fn pin_mut_param(x: &pin mut i32) {} | |
| 20 | | | |
| 21 | ||
| 22 | error[E0308]: mismatched types | |
| 23 | --> $DIR/ref-pat-suggestions.rs:9:20 | |
| 24 | | | |
| 25 | LL | fn pin_const_param(&pin const x: i32) {} | |
| 26 | | ^^^^^^^^^^^^ --- expected due to this | |
| 27 | | | | |
| 28 | | expected `i32`, found `Pin<&_>` | |
| 29 | | | |
| 30 | = note: expected type `i32` | |
| 31 | found struct `Pin<&_>` | |
| 32 | help: to take parameter `x` by reference, move `&pin const` to the type | |
| 33 | | | |
| 34 | LL - fn pin_const_param(&pin const x: i32) {} | |
| 35 | LL + fn pin_const_param(x: &pin const i32) {} | |
| 36 | | | |
| 37 | ||
| 38 | error: aborting due to 2 previous errors | |
| 39 | ||
| 40 | For more information about this error, try `rustc --explain E0308`. |
tests/ui/resolve/extern-prelude.rs+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //@ build-pass (FIXME(62277): could be check-pass?) | |
| 1 | //@ check-pass | |
| 2 | 2 | //@ compile-flags:--extern extern_prelude --extern Vec |
| 3 | 3 | //@ aux-build:extern-prelude.rs |
| 4 | 4 | //@ aux-build:extern-prelude-vec.rs |
yarn.lock+4-4| ... | ... | @@ -290,10 +290,10 @@ braces@^3.0.3: |
| 290 | 290 | dependencies: |
| 291 | 291 | fill-range "^7.1.1" |
| 292 | 292 | |
| 293 | browser-ui-test@^0.23.3: | |
| 294 | version "0.23.3" | |
| 295 | resolved "https://registry.yarnpkg.com/browser-ui-test/-/browser-ui-test-0.23.3.tgz#fe3b978cfe43d09ee9edd4b9d939a936dd654c30" | |
| 296 | integrity sha512-VWiRH7sSwpnQSe1Rll5iOPS+IeFa1rMThCXrP5Pwspm95OOA8Wylv2B6yqreEw25DE3qPmgJUeZZC7Uh9wnjSg== | |
| 293 | browser-ui-test@^0.23.5: | |
| 294 | version "0.23.5" | |
| 295 | resolved "https://registry.yarnpkg.com/browser-ui-test/-/browser-ui-test-0.23.5.tgz#f8fab778a1e00f339f53bb44e76ad14c5b57ce4f" | |
| 296 | integrity sha512-S4ztxfOa3vSqV86xS6huIrA8MKSrSqfZUFJfAgEN29U17eRtrYQt/ZGKYJBUP5sv5UYH6ZgnE05z8+Werm/8sw== | |
| 297 | 297 | dependencies: |
| 298 | 298 | css-unit-converter "^1.1.2" |
| 299 | 299 | pngjs "^3.4.0" |