jiebi/CodeConvo huggingface dataset:
--> $DIR/cast-rfc0401.rs:41:13 | LL |     let _ = 0x61u32 as char; <del> |             ^^^^^^^^^^^^^^^ invalid cast | help: try `char::from_u32` instead --> $DIR/cast-rfc0401.rs:41:13 | LL |     let _ = 0x61u32 as char; </del> |             ^^^^^^^^^^^^^^^ <ins> |             | |             invalid cast |             help: try `char::from_u32` instead: `char::from_u32(0x61u32)` </ins> error[E0606]: casting `bool` as `f32` is invalid --> $DIR/cast-rfc0401.rs:43:13
let second_input_ty = self.resolve_vars_if_possible(expected_input_tys[second_idx]); let third_input_ty = <del> self.resolve_vars_if_possible(expected_input_tys[second_idx]); </del> <ins> self.resolve_vars_if_possible(expected_input_tys[third_idx]); </ins> let span = if third_idx < provided_arg_count { let first_arg_span = provided_args[first_idx].span; let third_arg_span = provided_args[third_idx].span;
} missing_idxs => { let first_idx = *missing_idxs.first().unwrap(); <del> let second_idx = *missing_idxs.last().unwrap(); </del> <ins> let last_idx = *missing_idxs.last().unwrap(); </ins> // NOTE: Because we might be re-arranging arguments, might have extra arguments, etc. // It's hard to *really* know where we should provide this error label, so this is a // decent heuristic <del> let span = if first_idx < provided_arg_count { </del> <ins> let span = if last_idx < provided_arg_count { </ins> let first_arg_span = provided_args[first_idx].span; <del> let second_arg_span = provided_args[second_idx].span; </del> <ins> let last_arg_span = provided_args[last_idx].span; </ins> Span::new( first_arg_span.lo(), <del> second_arg_span.hi(), </del> <ins> last_arg_span.hi(), </ins> first_arg_span.ctxt(), None, )
<ins> error[E0061]: this function takes 6 arguments but 2 arguments were supplied --> $DIR/issue-97197.rs:2:5 | LL |     g((), ()); |     ^-------- multiple arguments are missing | note: function defined here --> $DIR/issue-97197.rs:6:8 | LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} |        ^ ------  --------  --------  --------  --------  ------ help: provide the arguments | LL |     g((), {bool}, {bool}, {bool}, {bool}, ()); |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error For more information about this error, try `rustc --explain E0061`. </ins>
--> $DIR/missing_arguments.rs:39:3 | LL |   complex(   1,                     ""   ); <del> |   ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `i32` are missing </del> <ins> |   ^^^^^^^--------------------------------- three arguments of type `f32`, `i32`, and `f32` are missing </ins> | note: function defined here --> $DIR/missing_arguments.rs:7:4
] [[package]] <ins> name = "crossbeam" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845" dependencies = [ "cfg-if 1.0.0", "crossbeam-channel", "crossbeam-deque", "crossbeam-epoch", "crossbeam-queue", "crossbeam-utils", ] [[package]] </ins> name = "crossbeam-channel" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index"
] [[package]] <ins> name = "crossbeam-queue" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", ] [[package]] </ins> name = "crossbeam-utils" version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index"
version = "0.1.0" dependencies = [ "colored", <del> "compiletest_rs", </del> "env_logger 0.9.0", "getrandom 0.2.0", <ins> "lazy_static", </ins> "libc", "log", "measureme 9.1.2", "rand 0.8.5", <ins> "regex", </ins> "rustc-workspace-hack", <del> "rustc_version", </del> "shell-escape", "smallvec", <ins> "ui_test", </ins> ] [[package]]
] [[package]] <ins> name = "pretty_assertions" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563" dependencies = [ "ansi_term", "ctor", "diff", "output_vt100", ] [[package]] </ins> name = "pretty_env_logger" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] <ins> name = "ui_test" version = "0.1.0" dependencies = [ "colored", "crossbeam", "lazy_static", "pretty_assertions 1.2.1", "regex", "rustc_version", ] [[package]] </ins> name = "unic-char-property" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index"
<ins> // check-pass #[allow(unused)] fn test<T, F, U>(f: F) -> Box<dyn Fn(T) -> U + 'static> where F: 'static + Fn(T) -> U, for<'a> U: 'a, // < This is the problematic line, see #97607 { Box::new(move |t| f(t)) } fn main() {} </ins>
let llvm_selfprofiler = llvm_profiler.as_mut().map(|s| s as *mut _ as *mut c_void).unwrap_or(std::ptr::null_mut()); <del> let extra_passes = config.passes.join(","); </del> <ins> let extra_passes = if !is_lto { config.passes.join(",") } else { "".to_string() }; </ins> let llvm_plugins = config.llvm_plugins.join(",");
} fn variances_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[ty::Variance] { <ins> // Skip items with no generics - there's nothing to infer in them. if tcx.generics_of(item_def_id).count() == 0 { return &[]; } </ins> match tcx.def_kind(item_def_id) { DefKind::Fn | DefKind::AssocFn
<ins> error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/issue-98260.rs:3:27 | LL |     fn a(aa: B) -> Result<_, B> { |                    -------^---- |                    |      | |                    |      not allowed in type signatures |                    help: replace with the correct return type: `Result<(), B>` error: aborting due to previous error For more information about this error, try `rustc --explain E0121`. </ins>
Self::with_capacity_in(capacity, Global) } <del> /// Creates a `Vec<T>` directly from the raw components of another vector. </del> <ins> /// Creates a `Vec<T>` directly from a pointer, a capacity, and a length. </ins> /// /// # Safety /// /// This is highly unsafe, due to the number of invariants that aren't /// checked: /// <del> /// * `ptr` needs to have been previously allocated via [`String`]/`Vec<T>` ///   (at least, it's highly likely to be incorrect if it wasn't). </del> /// * `T` needs to have the same alignment as what `ptr` was allocated with. ///   (`T` having a less strict alignment is not sufficient, the alignment really ///   needs to be equal to satisfy the [`dealloc`] requirement that memory must be
///   to be the same size as the pointer was allocated with. (Because similar to ///   alignment, [`dealloc`] must be called with the same layout `size`.) /// * `length` needs to be less than or equal to `capacity`. <ins> /// * The first `length` values must be properly initialized values of type `T`. /// * `capacity` needs to be the capacity that the pointer was allocated with. /// * The allocated size in bytes must be no larger than `isize::MAX`. ///   See the safety documentation of [`pointer::offset`]. /// /// These requirements are always upheld by any `ptr` that has been allocated /// via `Vec<T>`. Other allocation sources are allowed if the invariants are /// upheld. </ins> /// /// Violating these may cause problems like corrupting the allocator's /// internal data structures. For example it is normally **not** safe
///     assert_eq!(rebuilt, [4, 5, 6]); /// } /// ``` <ins> /// /// Using memory that was allocated elsewhere: /// /// ```rust /// #![feature(allocator_api)] /// /// use std::alloc::{AllocError, Allocator, Global, Layout}; /// /// fn main() { ///     let layout = Layout::array::<u32>(16).expect("overflow cannot happen"); /// ///     let vec = unsafe { ///         let mem = match Global.allocate(layout) { ///             Ok(mem) => mem.cast::<u32>().as_ptr(), ///             Err(AllocError) => return, ///         }; /// ///         mem.write(1_000_000); /// ///         Vec::from_raw_parts_in(mem, 1, 16, Global) ///     }; /// ///     assert_eq!(vec, &[1_000_000]); ///     assert_eq!(vec.capacity(), 16); /// } /// ``` </ins> #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Self {
Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 } } <del> /// Creates a `Vec<T, A>` directly from the raw components of another vector. </del> <ins> /// Creates a `Vec<T, A>` directly from a pointer, a capacity, a length, /// and an allocator. </ins> /// /// # Safety /// /// This is highly unsafe, due to the number of invariants that aren't /// checked: /// <del> /// * `ptr` needs to have been previously allocated via [`String`]/`Vec<T>` ///   (at least, it's highly likely to be incorrect if it wasn't). /// * `T` needs to have the same size and alignment as what `ptr` was allocated with. </del> <ins> /// * `T` needs to have the same alignment as what `ptr` was allocated with. </ins> ///   (`T` having a less strict alignment is not sufficient, the alignment really ///   needs to be equal to satisfy the [`dealloc`] requirement that memory must be ///   allocated and deallocated with the same layout.) <ins> /// * The size of `T` times the `capacity` (ie. the allocated size in bytes) needs ///   to be the same size as the pointer was allocated with. (Because similar to ///   alignment, [`dealloc`] must be called with the same layout `size`.) </ins> /// * `length` needs to be less than or equal to `capacity`. <del> /// * `capacity` needs to be the capacity that the pointer was allocated with. </del> <ins> /// * The first `length` values must be properly initialized values of type `T`. /// * `capacity` needs to [*fit*] the layout size that the pointer was allocated with. /// * The allocated size in bytes must be no larger than `isize::MAX`. ///   See the safety documentation of [`pointer::offset`]. /// /// These requirements are always upheld by any `ptr` that has been allocated /// via `Vec<T, A>`. Other allocation sources are allowed if the invariants are /// upheld. </ins> /// /// Violating these may cause problems like corrupting the allocator's /// internal data structures. For example it is **not** safe
///     assert_eq!(rebuilt, [4, 5, 6]); /// } /// ``` <ins> /// /// Using memory that was allocated elsewhere: /// /// ```rust /// use std::alloc::{alloc, Layout}; /// /// fn main() { ///     let layout = Layout::array::<u32>(16).expect("overflow cannot happen"); ///     let vec = unsafe { ///         let mem = alloc(layout).cast::<u32>(); ///         if mem.is_null() { ///             return; ///         } /// ///         mem.write(1_000_000); /// ///         Vec::from_raw_parts(mem, 1, 16) ///     }; /// ///     assert_eq!(vec, &[1_000_000]); ///     assert_eq!(vec.capacity(), 16); /// } /// ``` </ins> #[inline] #[unstable(feature = "allocator_api", issue = "32838")] pub unsafe fn from_raw_parts_in(ptr: *mut T, length: usize, capacity: usize, alloc: A) -> Self {
self.set_tainted_by_errors(); let tcx = self.tcx; <ins> // Precompute the provided types and spans, since that's all we typically need for below let provided_arg_tys: IndexVec<ProvidedIdx, (Ty<'tcx>, Span)> = provided_args .iter() .map(|expr| { let ty = self .typeck_results .borrow() .expr_ty_adjusted_opt(*expr) .unwrap_or_else(|| tcx.ty_error()); (self.resolve_vars_if_possible(ty), expr.span) }) .collect(); </ins> // A "softer" version of the `demand_compatible`, which checks types without persisting them, // and treats error types differently // This will allow us to "probe" for other argument orders that would likely have been correct
return Compatibility::Incompatible(None); } <del> let provided_arg: &hir::Expr<'tcx> = &provided_args[provided_idx]; let expectation = Expectation::rvalue_hint(self, expected_input_ty); // FIXME: check that this is safe; I don't believe this commits any of the obligations, but I can't be sure. // //   I had another method of "soft" type checking before, //   but it was failing to find the type of some expressions (like "") //   so I prodded this method and made it pub(super) so I could call it, and it seems to work well. let checked_ty = self.check_expr_kind(provided_arg, expectation); </del> <ins> let (arg_ty, arg_span) = provided_arg_tys[provided_idx]; let expectation = Expectation::rvalue_hint(self, expected_input_ty); </ins> let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); <del> let can_coerce = self.can_coerce(checked_ty, coerced_ty); </del> <ins> let can_coerce = self.can_coerce(arg_ty, coerced_ty); </ins> if !can_coerce { return Compatibility::Incompatible(None); } // Using probe here, since we don't want this subtyping to affect inference. let subtyping_error = self.probe(|_| { <del> self.at(&self.misc(provided_arg.span), self.param_env) .sup(formal_input_ty, coerced_ty) .err() </del> <ins> self.at(&self.misc(arg_span), self.param_env).sup(formal_input_ty, coerced_ty).err() </ins> }); // Same as above: if either the coerce type or the checked type is an error type, // consider them *not* compatible. <del> let references_error = (coerced_ty, checked_ty).references_error(); </del> <ins> let references_error = (coerced_ty, arg_ty).references_error(); </ins> match (references_error, subtyping_error) { (false, None) => Compatibility::Compatible, (_, subtyping_error) => Compatibility::Incompatible(subtyping_error),
ArgMatrix::new(provided_args.len(), formal_and_expected_inputs.len(), check_compatible) .find_errors(); <del> // Precompute the provided types and spans, since that's all we typically need for below let provided_arg_tys: IndexVec<ProvidedIdx, (Ty<'tcx>, Span)> = provided_args .iter() .map(|expr| { let ty = self .typeck_results .borrow() .expr_ty_adjusted_opt(*expr) .unwrap_or_else(|| tcx.ty_error()); (self.resolve_vars_if_possible(ty), expr.span) }) .collect(); </del> // First, check if we just need to wrap some arguments in a tuple. if let Some((mismatch_idx, terr)) = compatibility_diagonal.iter().enumerate().find_map(|(i, c)| {
<del> error[E0308]: mismatched types --> $DIR/issue-3044.rs:3:35 | LL |       needlesArr.iter().fold(|x, y| { |  ____________________________------_^ | |                            | | |                            the expected closure LL | |     }); | |_____^ expected closure, found `()` | = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 3:34]` found unit type `()` </del> error[E0061]: this function takes 2 arguments but 1 argument was supplied --> $DIR/issue-3044.rs:3:23 | LL |       needlesArr.iter().fold(|x, y| { |  _______________________^^^^- <ins> LL | | </ins> LL | |     }); | |______- an argument is missing |
help: provide the argument | LL ~     needlesArr.iter().fold(|x, y| { <ins> LL + </ins> LL ~     }, /* value */); | <del> error: aborting due to 2 previous errors </del> <ins> error: aborting due to previous error </ins> <del> Some errors have detailed explanations: E0061, E0308. For more information about an error, try `rustc --explain E0061`. </del> <ins> For more information about this error, try `rustc --explain E0061`. </ins>
use rustc_lint_defs::builtin::NAMED_ARGUMENTS_USED_POSITIONALLY; use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics, LintId}; <del> use rustc_parse_format::{Count, FormatSpec}; </del> <ins> use rustc_parse_format::Count; </ins> use std::borrow::Cow; use std::collections::hash_map::Entry;
} _ => {} }; <del> match a.format { FormatSpec { width: Count::CountIsName(s, _), .. } | FormatSpec { precision: Count::CountIsName(s, _), .. } => { used_argument_names.insert(s); } _ => {} }; </del> <ins> if let Count::CountIsName(s, _) = a.format.width { used_argument_names.insert(s); } if let Count::CountIsName(s, _) = a.format.precision { used_argument_names.insert(s); } </ins> } } for (symbol, (index, span)) in names { if !used_argument_names.contains(symbol.as_str()) { let msg = format!("named argument `{}` is not used by name", symbol.as_str()); <del> let arg_span = cx.arg_spans[index]; </del> <ins> let arg_span = cx.arg_spans.get(index).copied(); </ins> cx.ecx.buffered_early_lint.push(BufferedEarlyLint { span: MultiSpan::from_span(span), msg: msg.clone(),
}, BuiltinLintDiagnostics::NamedArgumentUsedPositionally(positional_arg, named_arg, name) => { db.span_label(named_arg, "this named argument is only referred to by position in formatting string"); <del> let msg = format!("this formatting argument uses named argument `{}` by position", name); db.span_label(positional_arg, msg); db.span_suggestion_verbose( positional_arg, "use the named argument by name to avoid ambiguity", format!("{{{}}}", name), Applicability::MaybeIncorrect, ); </del> <ins> if let Some(positional_arg) = positional_arg { let msg = format!("this formatting argument uses named argument `{}` by position", name); db.span_label(positional_arg, msg); db.span_suggestion_verbose( positional_arg, "use the named argument by name to avoid ambiguity", format!("{{{}}}", name), Applicability::MaybeIncorrect, ); } </ins> } } // Rewrap `db`, and pass control to the user.
<ins> // check-pass #![deny(named_arguments_used_positionally)] fn main() { let value: f64 = 314.15926; let digits_before_decimal = 1; let digits_after_decimal = 2; let width = digits_before_decimal + 1 + digits_after_decimal; println!( "{value:0>width$.digits_after_decimal$}", value = value, width = width, digits_after_decimal = digits_after_decimal, ); } </ins>
/// Parses an enum declaration. fn parse_item_enum(&mut self) -> PResult<'a, ItemInfo> { <ins> if self.token.is_keyword(kw::Struct) { let mut err = self.struct_span_err( self.prev_token.span.to(self.token.span), "`enum` and `struct` are mutually exclusive", ); err.span_suggestion( self.prev_token.span.to(self.token.span), "replace `enum struct` with", "enum", Applicability::MachineApplicable, ); if self.look_ahead(1, |t| t.is_ident()) { self.bump(); err.emit(); } else { return Err(err); } } </ins> let id = self.parse_ident()?; let mut generics = self.parse_generics()?; generics.where_clause = self.parse_where_clause()?;
} else { if matches!(def_kind, DefKind::AnonConst) && tcx.lazy_normalization() { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); <ins> let parent_def_id = tcx.hir().get_parent_item(hir_id); </ins> if tcx.hir().opt_const_param_default_param_hir_id(hir_id).is_some() { // In `generics_of` we set the generics' parent to be our parent's parent which means that // we lose out on the predicates of our actual parent if we dont return those predicates here.
//        parent of generics returned by `generics_of` // // In the above code we want the anon const to have predicates in its param env for `T: Trait` <del> let item_def_id = tcx.hir().get_parent_item(hir_id); // In the above code example we would be calling `explicit_predicates_of(Foo)` here </del> <ins> // and we would be calling `explicit_predicates_of(Foo)` here return tcx.explicit_predicates_of(parent_def_id); } let parent_def_kind = tcx.def_kind(parent_def_id); if matches!(parent_def_kind, DefKind::OpaqueTy) { // In `instantiate_identity` we inherit the predicates of our parent. // However, opaque types do not have a parent (see `gather_explicit_predicates_of`), which means // that we lose out on the predicates of our actual parent if we dont return those predicates here. // // // fn foo<T: Trait>() -> impl Iterator<Output = Another<{ <T as Trait>::ASSOC }> > { todo!() } //                                                        ^^^^^^^^^^^^^^^^^^^ the def id we are calling //                                                                            explicit_predicates_of on // // In the above code we want the anon const to have predicates in its param env for `T: Trait`. // However, the anon const cannot inherit predicates from its parent since it's opaque. // // To fix this, we call `explicit_predicates_of` directly on `foo`, the parent's parent. // In the above example this is `foo::{opaque#0}` or `impl Iterator` let parent_hir_id = tcx.hir().local_def_id_to_hir_id(parent_def_id.def_id); // In the above example this is the function `foo` let item_def_id = tcx.hir().get_parent_item(parent_hir_id); // In the above code example we would be calling `explicit_predicates_of(foo)` here </ins> return tcx.explicit_predicates_of(item_def_id); } }
<ins> // check-pass #![crate_type = "lib"] #![feature(generic_const_exprs)] #![allow(incomplete_features)] pub trait MyIterator { type Output; } pub trait Foo { const ABC: usize; } pub struct IteratorStruct<const N: usize>{ } pub struct Bar<const N: usize> { pub data: [usize; N] } impl<const N: usize> MyIterator for IteratorStruct<N> { type Output = Bar<N>; } pub fn test1<T: Foo>() -> impl MyIterator<Output = Bar<{T::ABC}>> where [(); T::ABC]: Sized { IteratorStruct::<{T::ABC}>{} } pub trait Baz<const N: usize>{} impl<const N: usize> Baz<N> for Bar<N> {} pub fn test2<T: Foo>() -> impl MyIterator<Output = impl Baz<{ T::ABC }>> where [(); T::ABC]: Sized { IteratorStruct::<{T::ABC}>{} } </ins>
builder.update_submodule(&Path::new("library").join("stdarch")); <ins> // Profiler information requires LLVM's compiler-rt if builder.config.profiler { builder.update_submodule(&Path::new("src/llvm-project")); } </ins> let mut target_deps = builder.ensure(StartupObjects { compiler, target }); let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target);