jiebi/CodeConvo huggingface dataset:
<ins> // MIR for `hey` 0 mir_map fn hey(_1: &[T]) -> () { debug it => _1;                      // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 let mut _0: ();                      // return place in scope 0 at $DIR/issue-91633.rs:+1:2: +1:2 let mut _2: &<[T] as std::ops::Index<usize>>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 let _3: &<[T] as std::ops::Index<usize>>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 let mut _4: &[T];                    // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 scope 1 { } bb0: { StorageLive(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 StorageLive(_3);                 // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 StorageLive(_4);                 // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 _4 = &(*_1);                     // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 _3 = <[T] as Index<usize>>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 // mir::Constant // + span: $DIR/issue-91633.rs:7:15: 7:20 // + literal: Const { ty: for<'r> fn(&'r [T], usize) -> &'r <[T] as Index<usize>>::Output {<[T] as Index<usize>>::index}, val: Value(<ZST>) } } bb1: { StorageDead(_4);                 // scope 0 at $DIR/issue-91633.rs:+4:19: +4:20 _2 = &(*_3);                     // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 StorageDead(_2);                 // scope 0 at $DIR/issue-91633.rs:+4:20: +4:21 _0 = const ();                   // scope 0 at $DIR/issue-91633.rs:+3:2: +5:3 StorageDead(_3);                 // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3 return;                          // scope 0 at $DIR/issue-91633.rs:+5:3: +5:3 } bb2 (cleanup): { resume;                          // scope 0 at $DIR/issue-91633.rs:+0:1: +5:3 } } </ins>
db.span_note(glob_reexport_span, format!("the name `{}` in the {} namespace is supposed to be publicly re-exported here", name, namespace)); db.span_note(private_item_span, "but the private item here shadows it".to_owned()); } <ins> BuiltinLintDiagnostics::UnusedQualifications { path_span, unqualified_path } => { db.span_suggestion_verbose( path_span, "replace it with the unqualified path", unqualified_path, Applicability::MachineApplicable ); } </ins> } // Rewrap `db`, and pass control to the user. decorate(db)
}; if res == unqualified_result { let lint = lint::builtin::UNUSED_QUALIFICATIONS; <del> self.r.lint_buffer.buffer_lint( </del> <ins> self.r.lint_buffer.buffer_lint_with_diagnostic( </ins> lint, finalize.node_id, finalize.path_span, "unnecessary qualification", <ins> lint::BuiltinLintDiagnostics::UnusedQualifications { path_span: finalize.path_span, unqualified_path: path.last().unwrap().ident } </ins> ) } }
<ins> error: unnecessary qualification --> $DIR/unused-qualifications-suggestion.rs:17:5 | LL |     foo::bar(); |     ^^^^^^^^ | note: the lint level is defined here --> $DIR/unused-qualifications-suggestion.rs:3:9 | LL | #![deny(unused_qualifications)] |         ^^^^^^^^^^^^^^^^^^^^^ help: replace it with the unqualified path | LL |     bar(); |     ~~~ error: unnecessary qualification --> $DIR/unused-qualifications-suggestion.rs:21:5 | LL |     baz::qux::quux(); |     ^^^^^^^^^^^^^^ | help: replace it with the unqualified path | LL |     quux(); |     ~~~~ error: aborting due to 2 previous errors </ins>
<ins> // edition:2021 use std::iter; fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> { //~^ ERROR: missing generics for struct `Vec` [E0107] iter::empty() //~ ERROR: type annotations needed [E0282] } fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> { //~^ ERROR: type annotations needed [E0282] f(data).filter(|x| x == target) } fn main() {} </ins>
<ins> error[E0107]: missing generics for struct `Vec` --> $DIR/issue-92305.rs:5:45 | LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> { |                                             ^^^ expected at least 1 generic argument | note: struct defined here, with at least 1 generic parameter: `T` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { |            ^^^ - help: add missing generic argument | LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> { |                                             ~~~~~~ error[E0282]: type annotations needed --> $DIR/issue-92305.rs:7:5 | LL |     iter::empty() |     ^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the function `empty` error[E0282]: type annotations needed --> $DIR/issue-92305.rs:10:35 | LL | fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> { |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 3 previous errors Some errors have detailed explanations: E0107, E0282. For more information about an error, try `rustc --explain E0107`. </ins>
saved_locals: &GeneratorSavedLocals, ) { let did = body.source.def_id(); <del> let allowed_upvars = tcx.erase_regions(upvars); </del> <ins> let param_env = tcx.param_env(did); let allowed_upvars = tcx.normalize_erasing_regions(param_env, upvars); </ins> let allowed = match witness.kind() { <del> &ty::GeneratorWitness(s) => tcx.erase_late_bound_regions(s), </del> <ins> &ty::GeneratorWitness(interior_tys) => { tcx.normalize_erasing_late_bound_regions(param_env, interior_tys) } </ins> _ => { tcx.sess.delay_span_bug( body.span,
<ins> // edition:2018 // run-pass #![allow(incomplete_features)] #![feature(generic_const_exprs)] #![allow(unused)] fn main() { let x = test(); } fn concat<const A: usize, const B: usize>(a: [f32; A], b: [f32; B]) -> [f32; A + B] { todo!() } async fn reverse<const A: usize>(x: [f32; A]) -> [f32; A] { todo!() } async fn test() { let a = [0.0]; let b = [1.0, 2.0]; let ab = concat(a,b); let ba = reverse(ab).await; println!("{:?}", ba); } </ins>
Extern functions may be called directly from Rust code as Rust uses large, contiguous stack segments like C. <del> ### Type definitions </del> <ins> ### Type aliases </ins> <del> A _type definition_ defines a new name for an existing [type](#types). Type definitions are declared with the keyword `type`. Every value has a single, </del> <ins> A _type alias_ defines a new name for an existing [type](#types). Type aliases are declared with the keyword `type`. Every value has a single, </ins> specific type; the type-specified aspects of a value include: * Whether the value is composed of sub-values or is indivisible.
<ins> // Regression test for <https://github.com/rust-lang/rust/issues/92859>. #![allow(incomplete_features)] #![feature(generic_const_exprs)] #![crate_name = "foo"] // @has 'foo/trait.Foo.html' pub trait Foo: Sized { const WIDTH: usize; fn arrayify(self) -> [Self; Self::WIDTH]; } impl<T: Sized> Foo for T { const WIDTH: usize = 1; // @has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]'  // 'fn arrayify(self) -> [Self; Self::WIDTH]' fn arrayify(self) -> [Self; Self::WIDTH] { [self] } } </ins>
[[package]] name = "mdbook" <del> version = "0.4.14" </del> <ins> version = "0.4.15" </ins> source = "registry+https://github.com/rust-lang/crates.io-index" <del> checksum = "f6e77253c46a90eb7e96b2807201dab941a4db5ea05eca5aaaf7027395f352b3" </del> <ins> checksum = "241f10687eb3b4e0634b3b4e423f97c5f1efbd69dc9522e24a8b94583eeec3c6" </ins> dependencies = [ "ammonia", "anyhow",
[[package]] name = "pulldown-cmark" <del> version = "0.8.0" </del> <ins> version = "0.9.1" </ins> source = "registry+https://github.com/rust-lang/crates.io-index" <del> checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" </del> <ins> checksum = "34f197a544b0c9ab3ae46c359a7ec9cbbb5c7bf97054266fecb7ead794a181d6" </ins> dependencies = [ "bitflags", "getopts",
] [[package]] <del> name = "pulldown-cmark" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acd16514d1af5f7a71f909a44ef253cdb712a376d7ebc8ae4a471a9be9743548" dependencies = [ "bitflags", "memchr", "unicase", ] [[package]] </del> name = "punycode" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index"
debug!(?result, "CACHE MISS"); self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result); <del> stack.cache().on_completion(stack.dfn, |fresh_trait_pred, provisional_result| { self.insert_evaluation_cache( param_env, fresh_trait_pred, dep_node, provisional_result.max(result), ); }); </del> <ins> stack.cache().on_completion( stack.dfn, |fresh_trait_pred, provisional_result, provisional_dep_node| { // Create a new `DepNode` that has dependencies on: // * The `DepNode` for the original evaluation that resulted in a provisional cache // entry being crated // * The `DepNode` for the *current* evaluation, which resulted in us completing // provisional caches entries and inserting them into the evaluation cache // // This ensures that when a query reads this entry from the evaluation cache, // it will end up (transitively) dependening on all of the incr-comp dependencies // created during the evaluation of this trait. For example, evaluating a trait // will usually require us to invoke `type_of(field_def_id)` to determine the // constituent types, and we want any queries reading from this evaluation // cache entry to end up with a transitive `type_of(field_def_id`)` dependency. // // By using `in_task`, we're also creating an edge from the *current* query // to the newly-created `combined_dep_node`. This is probably redundant, // but it's better to add too many dep graph edges than to add too few // dep graph edges. let ((), combined_dep_node) = self.in_task(|this| { this.tcx().dep_graph.read_index(provisional_dep_node); this.tcx().dep_graph.read_index(dep_node); }); self.insert_evaluation_cache( param_env, fresh_trait_pred, combined_dep_node, provisional_result.max(result), ); }, ); </ins> } else { debug!(?result, "PROVISIONAL"); debug!(
from_dfn: usize, reached_depth: usize, result: EvaluationResult, <ins> /// The `DepNodeIndex` created for the `evaluate_stack` call for this provisional /// evaluation. When we create an entry in the evaluation cache using this provisional /// cache entry (see `on_completion`), we use this `dep_node` to ensure that future reads from /// the cache will have all of the necessary incr comp dependencies tracked. dep_node: DepNodeIndex, </ins> } impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
fn on_completion( &self, dfn: usize, <del> mut op: impl FnMut(ty::PolyTraitPredicate<'tcx>, EvaluationResult), </del> <ins> mut op: impl FnMut(ty::PolyTraitPredicate<'tcx>, EvaluationResult, DepNodeIndex), </ins> ) { debug!(?dfn, "on_completion");
<ins> // revisions: rpass1 rpass2 // Regression test for issue #92987 // Tests that we properly manage `DepNode`s during trait evaluation // involing an auto-trait cycle. #[cfg(rpass1)] struct CycleOne(Box<CycleTwo>); #[cfg(rpass2)] enum CycleOne { Variant(Box<CycleTwo>) } struct CycleTwo(CycleOne); fn assert_send<T: Send>() {} fn bar() { assert_send::<CycleOne>(); assert_send::<CycleTwo>(); } fn main() {} </ins>
<ins> // Regression test for #93205 #![crate_name = "foo"] mod generated { pub struct MyNewType; impl MyNewType { pub const FOO: Self = Self; } } pub use generated::MyNewType; mod prelude { impl super::MyNewType { /// An alias for [`Self::FOO`]. // @has 'foo/struct.MyNewType.html' '//a[@href="struct.MyNewType.html#associatedconstant.FOO"]' 'Self::FOO' pub const FOO2: Self = Self::FOO; } } </ins>
| = help: normalized in stderr note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg` <del> --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:538:19 </del> <ins> --> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:539:19 </ins> | LL |         arg: impl IntoDiagnosticArg, |                   ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg`
| LL | fn foo<T, K, W: Default, Z: Default>(t: T, k: K) -> Foo<T, K, W, Z> { |                 ^^^^^^^ required by this bound in `foo` <del> help: consider giving `foo` an explicit type, where the type for type parameter `W` is specified | LL |     let foo: Foo<i32, &str, W, Z> = foo(1, ""); |            ++++++++++++++++++++++ </del> help: consider specifying the type arguments in the function call | LL |     let foo = foo::<T, K, W, Z>(1, "");
| LL | fn bar<T, K, Z: Default>(t: T, k: K) -> Bar<T, K, Z> { |                 ^^^^^^^ required by this bound in `bar` <del> help: consider giving `bar` an explicit type, where the type for type parameter `Z` is specified | LL |     let bar: Bar<i32, &str, Z> = bar(1, ""); |            +++++++++++++++++++ </del> help: consider specifying the type arguments in the function call | LL |     let bar = bar::<T, K, Z>(1, "");
| LL |         K: Borrow<Q>, |            ^^^^^^^^^ required by this bound in `HashMap::<K, V, S>::get` <del> help: consider specifying the generic argument | LL |     opts.get::<Q>(opt.as_ref()); |             +++++ </del> help: consider specifying the type argument in the function call | LL |     opts.get::<Q>(opt.as_ref());
|    ---- required by a bound in this LL | where T : Convert<U> |           ^^^^^^^^^^ required by this bound in `test` <del> help: consider specifying the generic arguments | LL |     test::<i32, U>(22, std::default::Default::default()); |         ++++++++++ </del> help: consider specifying the type arguments in the function call | LL |     test::<T, U>(22, std::default::Default::default());
if self.has_root() { return false; } <del> let mut iter = self.path[self.prefix_len()..].iter(); </del> <ins> let mut iter = self.path[self.prefix_remaining()..].iter(); </ins> match (iter.next(), iter.next()) { (Some(&b'.'), None) => true, (Some(&b'.'), Some(&b)) => self.is_sep_byte(b),
assert_eq!(prefix, parse_prefix(r"/?C:windowssystem32notepad.exe")); assert_eq!(prefix, parse_prefix(r"?/C:windowssystem32notepad.exe")); } <ins> // See #93586 for more infomation. #[test] fn test_windows_prefix_components() { use crate::path::Path; let path = Path::new("C:"); let mut components = path.components(); let drive = components.next().expect("drive is expected here"); assert_eq!(drive.as_os_str(), OsStr::new("C:")); assert_eq!(components.as_path(), Path::new("")); } </ins>
this.visit_ty(&ty); } } <del> GenericParamKind::Const { ref ty, .. } => { </del> <ins> GenericParamKind::Const { ref ty, default } => { </ins> let was_in_const_generic = this.is_in_const_generic; this.is_in_const_generic = true; walk_list!(this, visit_param_bound, param.bounds); this.visit_ty(&ty); <ins> if let Some(default) = default { this.visit_body(this.tcx.hir().body(default.body)); } </ins> this.is_in_const_generic = was_in_const_generic; } }
<ins> error[E0771]: use of non-static lifetime `'a` in const generic --> $DIR/outer-lifetime-in-const-generic-default.rs:4:17 | LL |         let x: &'a (); |                 ^^ | = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> error: aborting due to previous error For more information about this error, try `rustc --explain E0771`. </ins>
// The new pass manager is enabled by default for LLVM >= 13. // This matches Clang, which also enables it since Clang 13. <del> // FIXME: There are some perf issues with the new pass manager // when targeting s390x, so it is temporarily disabled for that // arch, see https://github.com/rust-lang/rust/issues/89609 user_opt.unwrap_or_else(|| target_arch != "s390x" && llvm_util::get_version() >= (13, 0, 0)) </del> <ins> // There are some perf issues with the new pass manager when targeting // s390x with LLVM 13, so enable the new pass manager only with LLVM 14. // See https://github.com/rust-lang/rust/issues/89609. let min_version = if target_arch == "s390x" { 14 } else { 13 }; user_opt.unwrap_or_else(|| llvm_util::get_version() >= (min_version, 0, 0)) </ins> }
<ins> error[E0308]: mismatched types --> $DIR/issue-94176.rs:5:32 | LL | pub fn test(a: Option<u32>) -> Option<u32> { |        ----                    ^^^^^^^^^^^ expected enum `Option`, found `()` |        | |        implicitly returns `()` as its body has no tail or `return` expression | = note:   expected enum `Option<u32>` found unit type `()` help: consider returning the local binding `a` | LL ~     println!("Foo"); LL +     a | error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>
<ins> // // popped up in in #94012, where an alternative desugaring was // causing unreachable code errors #![feature(let_else)] #![deny(unused_variables)] #![deny(unreachable_code)] fn let_else_diverge() -> bool { let Some(_) = Some("test") else { let x = 5; //~ ERROR unused variable: `x` return false; }; return true; } fn main() { let_else_diverge(); } </ins>
<ins> error: unused variable: `x` --> $DIR/let-else-then-diverge.rs:11:13 | LL |         let x = 5; |             ^ help: if this is intentional, prefix it with an underscore: `_x` | note: the lint level is defined here --> $DIR/let-else-then-diverge.rs:6:9 | LL | #![deny(unused_variables)] |         ^^^^^^^^^^^^^^^^ error: aborting due to previous error </ins>
<ins> // check-pass #![feature(generic_const_exprs)] #![allow(incomplete_features)] #![deny(const_evaluatable_unchecked)] pub struct If<const CONDITION: bool>; pub trait True {} impl True for If<true> {} pub struct FixedI8<const FRAC: u32> { pub bits: i8, } impl<const FRAC_LHS: u32, const FRAC_RHS: u32> PartialEq<FixedI8<FRAC_RHS>> for FixedI8<FRAC_LHS> where If<{ FRAC_RHS <= 8 }>: True, { fn eq(&self, _rhs: &FixedI8<FRAC_RHS>) -> bool { unimplemented!() } } impl<const FRAC: u32> PartialEq<i8> for FixedI8<FRAC> { fn eq(&self, rhs: &i8) -> bool { let rhs_as_fixed = FixedI8::<0> { bits: *rhs }; PartialEq::eq(self, &rhs_as_fixed) } } fn main() {} </ins>
#[rustc_legacy_const_generics(0)] //~ ERROR #[rustc_legacy_const_generics] functions must only have fn foo8<X>() {} <ins> impl S { #[rustc_legacy_const_generics(0)] //~ ERROR attribute should be applied to a function fn foo9<const X: usize>() {} } </ins> #[rustc_legacy_const_generics] //~ ERROR malformed `rustc_legacy_const_generics` attribute fn bar1() {}
= help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) error: malformed `rustc_legacy_const_generics` attribute input <del> --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:32:1 </del> <ins> --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:37:1 </ins> | LL | #[rustc_legacy_const_generics] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]` error: malformed `rustc_legacy_const_generics` attribute input <del> --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:35:1 </del> <ins> --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:40:1 </ins> | LL | #[rustc_legacy_const_generics = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_legacy_const_generics(N)]`
|         - non-const generic parameter error: attribute should be applied to a function <ins> --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:33:5 | LL |     #[rustc_legacy_const_generics(0)] |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL |     fn foo9<const X: usize>() {} |     ---------------------------- not a function error: attribute should be applied to a function </ins> --> $DIR/invalid-rustc_legacy_const_generics-arguments.rs:25:5 | LL |     #[rustc_legacy_const_generics(1)]
deallocate(ptr, size, align); } <del> #[cfg(stage0, not(test))] #[lang="closure_exchange_malloc"] #[inline] #[allow(deprecated)] unsafe fn closure_exchange_malloc(drop_glue: fn(*mut u8), size: uint, align: uint) -> *mut u8 { let total_size = util::get_box_size(size, align); let p = allocate(total_size, 8); let alloc = p as *mut raw::Box<()>; (*alloc).drop_glue = drop_glue; alloc as *mut u8 } </del> // The minimum alignment guaranteed by the architecture. This value is used to // add fast paths for low alignment values. In practice, the alignment is a // constant at the call site and the branch will be optimized out.
flags: c_int) -> *mut c_void; fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; <del> #[cfg(stage0)] fn je_dallocx(ptr: *mut c_void, flags: c_int); #[cfg(not(stage0))] </del> fn je_sdallocx(ptr: *mut c_void, size: size_t, flags: c_int); fn je_nallocx(size: size_t, flags: c_int) -> size_t; fn je_malloc_stats_print(write_cb: Option<extern "C" fn(cbopaque: *mut c_void,
} #[inline] <del> #[cfg(stage0)] pub unsafe fn deallocate(ptr: *mut u8, _size: uint, align: uint) { let flags = align_to_flags(align); je_dallocx(ptr as *mut c_void, flags) } #[inline] #[cfg(not(stage0))] </del> pub unsafe fn deallocate(ptr: *mut u8, size: uint, align: uint) { let flags = align_to_flags(align); je_sdallocx(ptr as *mut c_void, size as size_t, flags)
<ins> S 2014-09-16 828e075 winnt-x86_64 ce1e9d7f6967bfa368853e7c968e1626cc319951 winnt-i386 a8bd994666dfe683a5d7922c7998500255780724 linux-x86_64 88ff474db96c6ffc5c1dc7a43442cbe1cd88c8a2 linux-i386 7a731891f726c8a0590b142a4e8924c5e8b22e8d freebsd-x86_64 e67a56f76484f775cd4836dedb2d1069ab5d7921 macos-i386 f48023648a77e89086f4a2b39d76b09e4fff032d macos-x86_64 2ad6457b2b3036f87eae7581d64ee5341a07fb06 </ins> S 2014-09-10 6faa4f3 winnt-x86_64 939eb546469cb936441cff3b6f2478f562f77c46 winnt-i386 cfe4f8b519bb9d62588f9310a8f94bc919d5423b
// `PathSegment`, for which there is no associated `'_` or `&T` with no explicit // lifetime. Instead, we simply create an implicit lifetime, which will be checked // later, at which point a suitable error will be emitted. <del> LifetimeRibKind::AnonymousPassThrough(..) | LifetimeRibKind::AnonymousReportError | LifetimeRibKind::Item => break, </del> <ins> LifetimeRibKind::AnonymousPassThrough(binder) => { res = LifetimeRes::Anonymous { binder, elided: true }; break; } LifetimeRibKind::AnonymousReportError | LifetimeRibKind::Item => { // FIXME(cjgillot) This resolution is wrong, but this does not matter // since these cases are erroneous anyway.  Lifetime resolution should // emit a "missing lifetime specifier" diagnostic. res = LifetimeRes::Anonymous { binder: DUMMY_NODE_ID, elided: true }; break; } </ins> _ => {} } } <del> let res = if error { LifetimeRes::Error } else { LifetimeRes::Anonymous { binder: segment_id, elided: true } }; </del> let node_ids = self.r.next_node_ids(expected_lifetimes); self.record_lifetime_res( segment_id,
// originating from macros, since the segment's span might be from a macro arg. segment.ident.span.find_ancestor_inside(path_span).unwrap_or(path_span) }; <del> if error { </del> <ins> if let LifetimeRes::Error = res { </ins> let sess = self.r.session; let mut err = rustc_errors::struct_span_err!( sess,
); err.span_label(self.span, "invalid cast"); if self.expr_ty.is_numeric() { <del> err.span_help( self.span, if self.expr_ty == fcx.tcx.types.i8 { "try casting from `u8` instead" } else if self.expr_ty == fcx.tcx.types.u32 { "try `char::from_u32` instead" } else { "try `char::from_u32` instead (via a `u32`)" }, ); </del> <ins> if self.expr_ty == fcx.tcx.types.u32 { match fcx.tcx.sess.source_map().span_to_snippet(self.expr.span) { Ok(snippet) => err.span_suggestion( self.span, "try `char::from_u32` instead", format!("char::from_u32({snippet})"), Applicability::MachineApplicable, ), Err(_) => err.span_help(self.span, "try `char::from_u32` instead"), }; } else if self.expr_ty == fcx.tcx.types.i8 { err.span_help(self.span, "try casting from `u8` instead"); } else { err.span_help(self.span, "try `char::from_u32` instead (via a `u32`)"); }; </ins> } err.emit(); }
--> $DIR/E0604.rs:2:5 | LL |     1u32 as char; <del> |     ^^^^^^^^^^^^ invalid cast | help: try `char::from_u32` instead --> $DIR/E0604.rs:2:5 | LL |     1u32 as char; </del> |     ^^^^^^^^^^^^ <ins> |     | |     invalid cast |     help: try `char::from_u32` instead: `char::from_u32(1u32)` </ins> error: aborting due to previous error
--> $DIR/error-festival.rs:25:5 | LL |     0u32 as char; <del> |     ^^^^^^^^^^^^ invalid cast | help: try `char::from_u32` instead --> $DIR/error-festival.rs:25:5 | LL |     0u32 as char; </del> |     ^^^^^^^^^^^^ <ins> |     | |     invalid cast |     help: try `char::from_u32` instead: `char::from_u32(0u32)` </ins> error[E0605]: non-primitive cast: `u8` as `Vec<u8>` --> $DIR/error-festival.rs:29:5