jiebi/CodeConvo huggingface dataset:
// be added explicitly if necessary, see the error in `fn link_rlib`) compiled // as an executable due to `--test`. Use whole-archive implicitly, like before // the introduction of native lib modifiers. <del> || (bundle != Some(false) && sess.opts.test) </del> <ins> || (whole_archive == None && bundle != Some(false) && sess.opts.test) </ins> { cmd.link_whole_staticlib( name,
# ignore-cross-compile -- compiling C++ code does not work well when cross-compiling <del> # This test case makes sure that native libraries are linked with --whole-archive semantics # when the `-bundle,+whole-archive` modifiers are applied to them. </del> <ins> # This test case makes sure that native libraries are linked with appropriate semantics # when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them. </ins> # # The test works by checking that the resulting executables produce the expected output, # part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work
-include ../../run-make-fulldeps/tools.mk <del> all: $(TMPDIR)/$(call BIN,directly_linked) $(TMPDIR)/$(call BIN,indirectly_linked) $(TMPDIR)/$(call BIN,indirectly_linked_via_attr) </del> <ins> all: $(TMPDIR)/$(call BIN,directly_linked)  $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive)  $(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive)  $(TMPDIR)/$(call BIN,indirectly_linked)  $(TMPDIR)/$(call BIN,indirectly_linked_via_attr) </ins> $(call RUN,directly_linked) | $(CGREP) 'static-initializer.directly_linked.' <ins> $(call RUN,directly_linked_test_plus_whole_archive) --nocapture | $(CGREP) 'static-initializer.' $(call RUN,directly_linked_test_minus_whole_archive) --nocapture | $(CGREP) -v 'static-initializer.' </ins> $(call RUN,indirectly_linked) | $(CGREP) 'static-initializer.indirectly_linked.' $(call RUN,indirectly_linked_via_attr) | $(CGREP) 'static-initializer.native_lib_in_src.'
$(TMPDIR)/$(call BIN,directly_linked): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) $(RUSTC) directly_linked.rs -l static:+whole-archive=c_static_lib_with_constructor <ins> # Native lib linked into test executable, +whole-archive $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) $(RUSTC) directly_linked_test_plus_whole_archive.rs --test -l static:+whole-archive=c_static_lib_with_constructor # Native lib linked into test executable, -whole-archive $(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) $(RUSTC) directly_linked_test_minus_whole_archive.rs --test -l static:-whole-archive=c_static_lib_with_constructor </ins> # Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable $(TMPDIR)/$(call BIN,indirectly_linked): $(TMPDIR)/librlib_with_cmdline_native_lib.rlib $(RUSTC) indirectly_linked.rs
} } Err(coercion_error) => { <ins> // Mark that we've failed to coerce the types here to suppress // any superfluous errors we might encounter while trying to // emit or provide suggestions on how to fix the initial error. fcx.set_tainted_by_errors(); </ins> let (expected, found) = if label_expression_as_expected { // In the case where this is a "forced unit", like // `break`, we want to call the `()` "expected"
<ins> #![recursion_limit = "5"] // To reduce noise //expect incompatible type error when ambiguous traits are in scope //and not an overflow error on the span in the main function. struct Ratio<T>(T); pub trait Pow { fn pow(self) -> Self; } impl<'a, T> Pow for &'a Ratio<T> where &'a T: Pow, { fn pow(self) -> Self { self } } fn downcast<'a, W: ?Sized>() -> std::io::Result<&'a W> { todo!() } struct Other; fn main() -> std::io::Result<()> { let other: Other = downcast()?;//~ERROR 28:24: 28:35: `?` operator has incompatible types Ok(()) } </ins>
<ins> error[E0308]: `?` operator has incompatible types --> $DIR/issue-100246.rs:28:24 | LL |     let other: Other = downcast()?; |                        ^^^^^^^^^^^ expected struct `Other`, found reference | = note: `?` operator cannot convert from `&_` to `Other` = note: expected struct `Other` found reference `&_` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>
} #[cfg(not(no_global_oom_handling))] <ins> #[stable(feature = "vec_from_array_ref", since = "CURRENT_RUSTC_VERSION")] impl<T: Clone, const N: usize> From<&[T; N]> for Vec<T> { /// Allocate a `Vec<T>` and fill it by cloning `s`'s items. /// /// # Examples /// /// ``` /// assert_eq!(Vec::from(&[1, 2, 3]), vec![1, 2, 3]); /// ``` fn from(s: &[T; N]) -> Vec<T> { Self::from(s.as_slice()) } } #[cfg(not(no_global_oom_handling))] #[stable(feature = "vec_from_array_ref", since = "CURRENT_RUSTC_VERSION")] impl<T: Clone, const N: usize> From<&mut [T; N]> for Vec<T> { /// Allocate a `Vec<T>` and fill it by cloning `s`'s items. /// /// # Examples /// /// ``` /// assert_eq!(Vec::from(&mut [1, 2, 3]), vec![1, 2, 3]); /// ``` fn from(s: &mut [T; N]) -> Vec<T> { Self::from(s.as_mut_slice()) } } #[cfg(not(no_global_oom_handling))] </ins> #[stable(feature = "vec_from_array", since = "1.44.0")] impl<T, const N: usize> From<[T; N]> for Vec<T> { /// Allocate a `Vec<T>` and move `s`'s items into it.
// Ensure all ZSTs have been freed. assert!(alloc.state.borrow().0.is_empty()); } <ins> #[test] fn test_vec_from_array_ref() { assert_eq!(Vec::from(&[1, 2, 3]), vec![1, 2, 3]); } #[test] fn test_vec_from_array_mut_ref() { assert_eq!(Vec::from(&mut [1, 2, 3]), vec![1, 2, 3]); } </ins>
let ai = &self.expected_indices; let ii = &self.provided_indices; <ins> // Issue: 100478, when we end the iteration, // `next_unmatched_idx` will point to the index of the first unmatched let mut next_unmatched_idx = 0; </ins> for i in 0..cmp::max(ai.len(), ii.len()) { <del> // If we eliminate the last row, any left-over inputs are considered missing </del> <ins> // If we eliminate the last row, any left-over arguments are considered missing </ins> if i >= mat.len() { <del> return Some(Issue::Missing(i)); </del> <ins> return Some(Issue::Missing(next_unmatched_idx)); </ins> } <del> // If we eliminate the last column, any left-over arguments are extra </del> <ins> // If we eliminate the last column, any left-over inputs are extra </ins> if mat[i].len() == 0 { <del> return Some(Issue::Extra(i)); </del> <ins> return Some(Issue::Extra(next_unmatched_idx)); </ins> } // Make sure we don't pass the bounds of our matrix
if matches!(c, Compatibility::Compatible) { Some(i) } else { None } }) .collect(); <del> if compat.len() != 1 { // this could go into multiple slots, don't bother exploring both </del> <ins> if compat.len() < 1 { // try to find a cycle even when this could go into multiple slots, see #101097 </ins> is_cycle = false; break; }
None => { // We didn't find any issues, so we need to push the algorithm forward // First, eliminate any arguments that currently satisfy their inputs <del> for (inp, arg) in self.eliminate_satisfied() { </del> <ins> let eliminated = self.eliminate_satisfied(); assert!(!eliminated.is_empty(), "didn't eliminated any indice in this round"); for (inp, arg) in eliminated { </ins> matched_inputs[arg] = Some(inp); } }
<ins> use std::sync::Arc; macro_rules! GenT { ($name:tt) => { #[derive(Default, Debug)] struct $name { #[allow(unused)] val: i32, } impl $name { #[allow(unused)] fn new(val: i32) -> Self { $name { val } } } }; } GenT!(T1); GenT!(T2); GenT!(T3); GenT!(T4); GenT!(T5); GenT!(T6); GenT!(T7); GenT!(T8); #[allow(unused)] fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8: Arc<T8>) {} fn three_diff(_a: T1, _b: T2, _c: T3) {} fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} fn main() { three_diff(T2::new(0)); //~ ERROR this function takes four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR 35:5: 35:17: arguments to this function are incorrect [E0308] four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308] let p1 = T1::new(0); let p2 = Arc::new(T2::new(0)); let p3 = T3::new(0); let p4 = Arc::new(T4::new(1)); let p5 = T5::new(0); let p6 = T6::new(0); let p7 = T7::new(0); let p8 = Arc::default(); foo( //~^ 47:5: 47:8: this function takes 8 arguments but 7 arguments were supplied [E0061] p1, //p2, p3, p4, p5, p6, p7, p8, ); } </ins>
<ins> error[E0061]: this function takes 3 arguments but 1 argument was supplied --> $DIR/issue-100478.rs:34:5 | LL |     three_diff(T2::new(0)); |     ^^^^^^^^^^------------ |               || |               |an argument of type `T1` is missing |               an argument of type `T3` is missing | note: function defined here --> $DIR/issue-100478.rs:30:4 | LL | fn three_diff(_a: T1, _b: T2, _c: T3) {} |    ^^^^^^^^^^ ------  ------  ------ help: provide the arguments | LL |     three_diff(/* T1 */, T2::new(0), /* T3 */); |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/issue-100478.rs:35:5 | LL |     four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); |     ^^^^^^^^^^^^ -------------  -------------  -------------  ------------- expected `T4`, found `T2` |                  |              |              | |                  |              |              expected `T3`, found `T1` |                  |              expected `T2`, found `T4` |                  expected `T1`, found `T3` | note: function defined here --> $DIR/issue-100478.rs:31:4 | LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} |    ^^^^^^^^^^^^ ------  ------  ------  ------ help: did you mean | LL |     four_shuffle(T1::default(), T2::default(), T3::default(), T4::default()); |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0308]: arguments to this function are incorrect --> $DIR/issue-100478.rs:36:5 | LL |     four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); |     ^^^^^^^^^^^^ -------------                 -------------  ------------- expected struct `T4`, found struct `T3` |                  |                             | |                  |                             expected `T3`, found `T1` |                  expected `T1`, found `T3` | note: function defined here --> $DIR/issue-100478.rs:31:4 | LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} |    ^^^^^^^^^^^^ ------  ------  ------  ------ help: swap these arguments | LL |     four_shuffle(T1::default(), T2::default(), T3::default(), /* T4 */); |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error[E0061]: this function takes 8 arguments but 7 arguments were supplied --> $DIR/issue-100478.rs:47:5 | LL |     foo( |     ^^^ ... LL |         p3, p4, p5, p6, p7, p8, |         -- an argument of type `Arc<T2>` is missing | note: function defined here --> $DIR/issue-100478.rs:29:4 | LL | fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8: Arc<T8>) {} |    ^^^ ------  -----------  ------  -----------  ------  ------  ------  ----------- help: provide the argument | LL |     foo(p1, /* Arc<T2> */, p3, p4, p5, p6, p7, p8); |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 4 previous errors Some errors have detailed explanations: E0061, E0308. For more information about an error, try `rustc --explain E0061`. </ins>
<ins> struct A; struct B; struct C; struct D; fn f( a1: A, a2: A, b1: B, b2: B, c1: C, c2: C, ) {} fn main() { f(C, A, A, A, B, B, C); //~ ERROR this function takes 6 arguments but 7 arguments were supplied [E0061] f(C, C, A, A, B, B);  //~ ERROR arguments to this function are incorrect [E0308] f(A, A, D, D, B, B);  //~ arguments to this function are incorrect [E0308] f(C, C, B, B, A, A);  //~ arguments to this function are incorrect [E0308] f(C, C, A, B, A, A);  //~ arguments to this function are incorrect [E0308] } </ins>
// NOTE: generics must be cleaned before args let generics = clean_generics(generics, cx); let args = clean_args_from_types_and_body_id(cx, sig.decl.inputs, body_id); <del> let decl = clean_fn_decl_with_args(cx, sig.decl, args); </del> <ins> let mut decl = clean_fn_decl_with_args(cx, sig.decl, args); if sig.header.is_async() { decl.output = decl.sugared_async_return_type(); } </ins> (generics, decl) }); Box::new(Function { decl, generics })
///   <br>Used to determine line-wrapping. /// * `indent`: The number of spaces to indent each successive line with, if line-wrapping is ///   necessary. <del> /// * `asyncness`: Whether the function is async or not. </del> pub(crate) fn full_print<'a, 'tcx: 'a>( &'a self, header_len: usize, indent: usize, <del> asyncness: hir::IsAsync, </del> cx: &'a Context<'tcx>, ) -> impl fmt::Display + 'a + Captures<'tcx> { <del> display_fn(move |f| self.inner_full_print(header_len, indent, asyncness, f, cx)) </del> <ins> display_fn(move |f| self.inner_full_print(header_len, indent, f, cx)) </ins> } fn inner_full_print( &self, header_len: usize, indent: usize, <del> asyncness: hir::IsAsync, </del> f: &mut fmt::Formatter<'_>, cx: &Context<'_>, ) -> fmt::Result {
args_plain.push_str(", ..."); } <del> let arrow_plain; let arrow = if let hir::IsAsync::Async = asyncness { let output = self.sugared_async_return_type(); arrow_plain = format!("{:#}", output.print(cx)); if f.alternate() { arrow_plain.clone() } else { format!("{}", output.print(cx)) } } else { arrow_plain = format!("{:#}", self.output.print(cx)); if f.alternate() { arrow_plain.clone() } else { format!("{}", self.output.print(cx)) } }; </del> <ins> let arrow_plain = format!("{:#}", self.output.print(cx)); let arrow = if f.alternate() { arrow_plain.clone() } else { format!("{}", self.output.print(cx)) }; </ins> let declaration_len = header_len + args_plain.len() + arrow_plain.len(); let output = if declaration_len > 80 {
href = href, name = name, generics = g.print(cx), <del> decl = d.full_print(header_len, indent, header.asyncness, cx), </del> <ins> decl = d.full_print(header_len, indent, cx), </ins> notable_traits = notable_traits_decl(d, cx), where_clause = print_where_clause(g, cx, indent, end_newline), )
name = name, generics = f.generics.print(cx), where_clause = print_where_clause(&f.generics, cx, 0, Ending::Newline), <del> decl = f.decl.full_print(header_len, 0, header.asyncness, cx), </del> <ins> decl = f.decl.full_print(header_len, 0, cx), </ins> notable_traits = notable_traits_decl(&f.decl, cx), ); });
<ins> // edition:2021 // ignore-tidy-linelength // Regression test for <https://github.com/rust-lang/rust/issues/101199> use std::future::Future; // @is "$.index[*][?(@.name=='get_int')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' // @is "$.index[*][?(@.name=='get_int')].inner.header.async" false pub fn get_int() -> i32 { 42 } // @is "$.index[*][?(@.name=='get_int_async')].inner.decl.output" '{"inner": "i32", "kind": "primitive"}' // @is "$.index[*][?(@.name=='get_int_async')].inner.header.async" true pub async fn get_int_async() -> i32 { 42 } // @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.kind" '"impl_trait"' // @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' // @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' // @is "$.index[*][?(@.name=='get_int_future')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' // @is "$.index[*][?(@.name=='get_int_future')].inner.header.async" false pub fn get_int_future() -> impl Future<Output = i32> { async { 42 } } // @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.kind" '"impl_trait"' // @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.name" '"Future"' // @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].name" '"Output"' // @is "$.index[*][?(@.name=='get_int_future_async')].inner.decl.output.inner[0].trait_bound.trait.args.angle_bracketed.bindings[0].binding.equality.type" '{"inner": "i32", "kind": "primitive"}' // @is "$.index[*][?(@.name=='get_int_future_async')].inner.header.async" true pub async fn get_int_future_async() -> impl Future<Output = i32> { async { 42 } } </ins>
<ins> // check-pass // edition:2021 // aux-build:test-macros.rs #![no_std] // Don't load unnecessary hygiene information from std extern crate std; #[macro_use] extern crate test_macros; macro_rules! foo { ($($path:ident)::*) => ( test_macros::recollect!( $($path)::* ) ) } macro_rules! baz { () => ( foo!($crate::BAR) ) } pub const BAR: u32 = 19; fn main(){ std::println!("{}", baz!()); } </ins>
<ins> error: expected one of `!` or `::`, found keyword `const` --> $DIR/public-instead-of-pub-3.rs:3:12 | LL |     public const X: i32 = 123; |            ^^^^^ expected one of `!` or `::` | help: write `pub` instead of `public` to make the item public | LL |     pub const X: i32 = 123; |     ~~~ error: aborting due to previous error </ins>
} /// When encountering an fn-like type, try accessing the output of the type <del> /// // and suggesting calling it if it satisfies a predicate (i.e. if the </del> <ins> /// and suggesting calling it if it satisfies a predicate (i.e. if the </ins> /// output has a method or a field): /// ```compile_fail,E0308 /// fn foo(x: usize) -> usize { x }
} else { err.span_suggestion(sp, &msg, suggestion, applicability); } <ins> } else if self.suggest_else_fn_with_closure(err, expr, found, expected) { </ins> } else if self.suggest_fn_call(err, expr, found, |output| self.can_coerce(output, expected)) && let ty::FnDef(def_id, ..) = &found.kind() && let Some(sp) = self.tcx.hir().span_if_local(*def_id)
} } <ins> /// issue #102320, for `unwrap_or` with closure as argument, suggest `unwrap_or_else` /// FIXME: currently not working for suggesting `map_or_else`, see #102408 pub(crate) fn suggest_else_fn_with_closure( &self, err: &mut Diagnostic, expr: &hir::Expr<'_>, found: Ty<'tcx>, expected: Ty<'tcx>, ) -> bool { let Some((_def_id_or_name, output, _inputs)) = self.extract_callable_info(expr, found) else { return false; }; if !self.can_coerce(output, expected) { return false; } let parent = self.tcx.hir().get_parent_node(expr.hir_id); if  let Some(Node::Expr(call_expr)) = self.tcx.hir().find(parent) && let hir::ExprKind::MethodCall( hir::PathSegment { ident: method_name, .. }, self_expr, args, .., ) = call_expr.kind && let Some(self_ty) = self.typeck_results.borrow().expr_ty_opt(self_expr) { let new_name = Ident { name: Symbol::intern(&format!("{}_else", method_name.as_str())), span: method_name.span, }; let probe = self.lookup_probe( expr.span, new_name, self_ty, self_expr, ProbeScope::TraitsInScope, ); // check the method arguments number if let Ok(pick) = probe && let fn_sig = self.tcx.fn_sig(pick.item.def_id) && let fn_args = fn_sig.skip_binder().inputs() && fn_args.len() == args.len() + 1 { err.span_suggestion_verbose( method_name.span.shrink_to_hi(), &format!("try calling `{}` instead", new_name.name.as_str()), "_else", Applicability::MaybeIncorrect, ); return true; } } false } </ins> /// Checks whether there is a local type somewhere in the chain of /// autoderefs of `rcvr_ty`. fn type_derefs_to_local(
<ins> error[E0308]: mismatched types --> $DIR/sugg-else-for-closure.rs:6:26 | LL |     let _s = y.unwrap_or(|| x.split('.').nth(1).unwrap()); |                --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&str`, found closure |                | |                arguments to this function are incorrect | = note: expected reference `&str` found closure `[closure@$DIR/sugg-else-for-closure.rs:6:26: 6:28]` note: associated function defined here --> $SRC_DIR/core/src/option.rs:LL:COL | LL |     pub const fn unwrap_or(self, default: T) -> T |                  ^^^^^^^^^ help: try calling `unwrap_or_else` instead | LL |     let _s = y.unwrap_or_else(|| x.split('.').nth(1).unwrap()); |                         +++++ error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>
imp::Thread::sleep(dur) } <ins> /// Used to ensure that `park` and `park_timeout` do not unwind, as that can /// cause undefined behaviour if not handled correctly (see #102398 for context). struct PanicGuard; impl Drop for PanicGuard { fn drop(&mut self) { rtabort!("an irrecoverable error occurred while synchronizing threads") } } </ins> /// Blocks unless or until the current thread's token is made available. /// /// A call to `park` does not guarantee that the thread will remain parked <del> /// forever, and callers should be prepared for this possibility. </del> <ins> /// forever, and callers should be prepared for this possibility. However, /// it is guaranteed that this function will not panic (it may abort the /// process if the implementation encounters some rare errors). </ins> /// /// # park and unpark ///
/// [`thread::park_timeout`]: park_timeout #[stable(feature = "rust1", since = "1.0.0")] pub fn park() { <ins> let guard = PanicGuard; </ins> // SAFETY: park_timeout is called on the parker owned by this thread. unsafe { current().inner.as_ref().parker().park(); } <ins> // No panic occurred, do not abort. forget(guard); </ins> } /// Use [`park_timeout`].
/// ``` #[stable(feature = "park_timeout", since = "1.4.0")] pub fn park_timeout(dur: Duration) { <ins> let guard = PanicGuard; </ins> // SAFETY: park_timeout is called on the parker owned by this thread. unsafe { current().inner.as_ref().parker().park_timeout(dur); } <ins> // No panic occurred, do not abort. forget(guard); </ins> } ////////////////////////////////////////////////////////////////////////////////
span: Span, origin: &hir::OpaqueTyOrigin, ) { <del> let hidden_type = tcx.bound_type_of(def_id.to_def_id()).subst(tcx, substs); </del> let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let defining_use_anchor = match *origin { hir::OpaqueTyOrigin::FnReturn(did) | hir::OpaqueTyOrigin::AsyncFn(did) => did,
let ocx = ObligationCtxt::new(&infcx); let opaque_ty = tcx.mk_opaque(def_id.to_def_id(), substs); <ins> // `ReErased` regions appear in the "parent_substs" of closures/generators. // We're ignoring them here and replacing them with fresh region variables. // See tests in ui/type-alias-impl-trait/closure_{parent_substs,wf_outlives}.rs. // // FIXME: Consider wrapping the hidden type in an existential `Binder` and instantiating it // here rather than using ReErased. let hidden_ty = tcx.bound_type_of(def_id.to_def_id()).subst(tcx, substs); let hidden_ty = tcx.fold_regions(hidden_ty, |re, _dbi| match re.kind() { ty::ReErased => infcx.next_region_var(RegionVariableOrigin::MiscVariable(span)), _ => re, }); </ins> let misc_cause = traits::ObligationCause::misc(span, hir_id); <del> match infcx.at(&misc_cause, param_env).eq(opaque_ty, hidden_type) { </del> <ins> match infcx.at(&misc_cause, param_env).eq(opaque_ty, hidden_ty) { </ins> Ok(infer_ok) => ocx.register_infer_ok_obligations(infer_ok), Err(ty_err) => { tcx.sess.delay_span_bug( span, <del> &format!("could not unify `{hidden_type}` with revealed type:n{ty_err}"), </del> <ins> &format!("could not unify `{hidden_ty}` with revealed type:n{ty_err}"), </ins> ); } }
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the // hidden type is well formed even without those bounds. let predicate = <del> ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_type.into())).to_predicate(tcx); </del> <ins> ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_ty.into())).to_predicate(tcx); </ins> ocx.register_obligation(Obligation::new(misc_cause, param_env, predicate)); // Check that all obligations are satisfied by the implementation's