jiebi/CodeConvo huggingface dataset:
.unwrap_or(false); let (res, self_ctor_substs) = if let Res::SelfCtor(impl_def_id) = res { <del> let ty = self.impl_self_ty(span, impl_def_id).ty; let adt_def = ty.ty_adt_def(); </del> <ins> let ty = self.normalize_ty(span, tcx.at(span).type_of(impl_def_id)); </ins> match ty.kind { ty::Adt(adt_def, substs) if adt_def.has_ctor() => { let variant = adt_def.non_enum_variant();
span, "the `Self` constructor can only be used with tuple or unit structs", ); <del> if let Some(adt_def) = adt_def { </del> <ins> if let Some(adt_def) = ty.ty_adt_def() { </ins> match adt_def.adt_kind() { AdtKind::Enum => { err.help("did you mean to use one of the enum's variants?");
<ins> fn main() {} struct S0<T>(T); impl<T> S0<T> { const C: S0<u8> = Self(0); //~^ ERROR mismatched types //~| ERROR mismatched types fn foo() { Self(0); //~^ ERROR mismatched types } } // Testing normalization. trait Fun { type Out; } impl<T> Fun for S0<T> { type Out = Self; } trait Foo<T> { fn foo(); } impl<T> Foo<T> for <S0<T> as Fun>::Out { fn foo() { Self(0); //~ ERROR mismatched types } } struct S1<T, U>(T, U); impl<T> S1<T, u8> { const C: S1<u8, u8> = Self(0, 1); //~^ ERROR mismatched types //~| ERROR mismatched types } struct S2<T>(T); impl<T> S2<T> { fn map<U>(x: U) -> S2<U> { Self(x) //~^ ERROR mismatched types //~| ERROR mismatched types } } </ins>
sig::set_bit(&mut r.sig, T::PRECISION - 1); } <del> // gcc forces the Quiet bit on, which means (float)(double)(float_sNan) // does not give you back the same bits. This is dubious, and we // don't currently do it. You're really supposed to get // an invalid operation signal at runtime, but nobody does that. status = Status::OK; </del> <ins> // Convert of sNaN creates qNaN and raises an exception (invalid op). // This also guarantees that a sNaN does not become Inf on a truncation // that loses all payload bits. if self.is_signaling() { // Quiet signaling NaN. sig::set_bit(&mut r.sig, T::QNAN_BIT); status = Status::INVALID_OP; } else { status = Status::OK; } </ins> } else { *loses_info = false; status = Status::OK;
} #[test] <ins> fn issue_69532() { let f = Double::from_bits(0x7FF0_0000_0000_0001u64 as u128); let mut loses_info = false; let sta = f.convert(&mut loses_info); let r: Single = sta.value; assert!(loses_info); assert!(r.is_nan()); assert_eq!(sta.status, Status::INVALID_OP); } #[test] </ins> fn min_num() { let f1 = Double::from_f64(1.0); let f2 = Double::from_f64(2.0);
assert_eq!(4294967295.0, test.to_f64()); assert!(!loses_info); <del> let test = Single::snan(None); let x87_snan = X87DoubleExtended::snan(None); let test: X87DoubleExtended = test.convert(&mut loses_info).value; assert!(test.bitwise_eq(x87_snan)); assert!(!loses_info); </del> let test = Single::qnan(None); let x87_qnan = X87DoubleExtended::qnan(None); let test: X87DoubleExtended = test.convert(&mut loses_info).value; assert!(test.bitwise_eq(x87_qnan)); assert!(!loses_info); <del> let test = X87DoubleExtended::snan(None); let test: X87DoubleExtended = test.convert(&mut loses_info).value; assert!(test.bitwise_eq(x87_snan)); </del> <ins> let test = Single::snan(None); let sta = test.convert(&mut loses_info); let test: X87DoubleExtended = sta.value; assert!(test.is_nan()); assert!(!test.is_signaling()); </ins> assert!(!loses_info); <ins> assert_eq!(sta.status, Status::INVALID_OP); </ins> let test = X87DoubleExtended::qnan(None); let test: X87DoubleExtended = test.convert(&mut loses_info).value; assert!(test.bitwise_eq(x87_qnan)); assert!(!loses_info); <ins> let test = X87DoubleExtended::snan(None); let sta = test.convert(&mut loses_info); let test: X87DoubleExtended = sta.value; assert!(test.is_nan()); assert!(!test.is_signaling()); assert!(!loses_info); assert_eq!(sta.status, Status::INVALID_OP); </ins> } #[test]
<ins> // run-pass #![feature(const_fn_transmute)] const fn make_nans() -> (f64, f64, f32, f32) { let nan1: f64 = unsafe { std::mem::transmute(0x7FF0_0001_0000_0001u64) }; let nan2: f64 = unsafe { std::mem::transmute(0x7FF0_0000_0000_0001u64) }; let nan1_32 = nan1 as f32; let nan2_32 = nan2 as f32; (nan1, nan2, nan1_32, nan2_32) } static NANS: (f64, f64, f32, f32) = make_nans(); fn main() { let (nan1, nan2, nan1_32, nan2_32) = NANS; assert!(nan1.is_nan()); assert!(nan2.is_nan()); assert!(nan1_32.is_nan()); assert!(nan2_32.is_nan()); } </ins>
(' ' | 'n' | 't', _) if eat_ws => { skips.push(pos); } <del> ('', Some((next_pos, 'n' | 't' | '0' | '' | ''' | '"'))) => { </del> <ins> ('', Some((next_pos, 'n' | 't' | 'r' | '0' | '' | ''' | '"'))) => { </ins> skips.push(*next_pos); let _ = s.next(); }
/// Checks whether the non-terminal may contain a single (non-keyword) identifier. fn may_be_ident(nt: &token::Nonterminal) -> bool { match *nt { <del> token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) => false, </del> <ins> token::NtItem(_) | token::NtBlock(_) | token::NtVis(_) | token::NtLifetime(_) => false, </ins> _ => true, } }
}; let sp = cx.with_def_site_ctxt(sp); <del> let e = match env::var(&var.as_str()) { Err(..) => { </del> <ins> let value = env::var(&var.as_str()).ok().as_deref().map(Symbol::intern); cx.parse_sess.env_depinfo.borrow_mut().insert((Symbol::intern(&var), value)); let e = match value { None => { </ins> let lt = cx.lifetime(sp, Ident::new(kw::StaticLifetime, sp)); cx.expr_path(cx.path_all( sp,
))], )) } <del> Ok(s) => cx.expr_call_global( </del> <ins> Some(value) => cx.expr_call_global( </ins> sp, cx.std_path(&[sym::option, sym::Option, sym::Some]), <del> vec![cx.expr_str(sp, Symbol::intern(&s))], </del> <ins> vec![cx.expr_str(sp, value)], </ins> ), }; MacEager::expr(e)
} let sp = cx.with_def_site_ctxt(sp); <del> let e = match env::var(&*var.as_str()) { Err(_) => { </del> <ins> let value = env::var(&*var.as_str()).ok().as_deref().map(Symbol::intern); cx.parse_sess.env_depinfo.borrow_mut().insert((var, value)); let e = match value { None => { </ins> cx.span_err(sp, &msg.as_str()); return DummyResult::any(sp); } <del> Ok(s) => cx.expr_str(sp, Symbol::intern(&s)), </del> <ins> Some(value) => cx.expr_str(sp, value), </ins> }; MacEager::expr(e) }
filename.to_string().replace(" ", " ") } <ins> // Makefile comments only need escaping newlines and ``. // The result can be unescaped by anything that can unescape `escape_default` and friends. fn escape_dep_env(symbol: Symbol) -> String { let s = symbol.as_str(); let mut escaped = String::with_capacity(s.len()); for c in s.chars() { match c { 'n' => escaped.push_str(r"n"), 'r' => escaped.push_str(r"r"), '' => escaped.push_str(r""), _ => escaped.push(c), } } escaped } </ins> fn write_out_deps( sess: &Session, boxed_resolver: &Steal<Rc<RefCell<BoxedResolver>>>,
for path in files { writeln!(file, "{}:", path)?; } <ins> // Emit special comments with information about accessed environment variables. let env_depinfo = sess.parse_sess.env_depinfo.borrow(); if !env_depinfo.is_empty() { let mut envs: Vec<_> = env_depinfo .iter() .map(|(k, v)| (escape_dep_env(*k), v.map(escape_dep_env))) .collect(); envs.sort_unstable(); writeln!(file)?; for (k, v) in envs { write!(file, "# env-dep:{}", k)?; if let Some(v) = v { write!(file, "={}", v)?; } writeln!(file)?; } } </ins> Ok(()) })();
<ins> -include ../../run-make-fulldeps/tools.mk all: EXISTING_ENV=1 EXISTING_OPT_ENV=1 $(RUSTC) --emit dep-info main.rs $(CGREP) "# env-dep:EXISTING_ENV=1" < $(TMPDIR)/main.d $(CGREP) "# env-dep:EXISTING_OPT_ENV=1" < $(TMPDIR)/main.d $(CGREP) "# env-dep:NONEXISTENT_OPT_ENV" < $(TMPDIR)/main.d $(CGREP) "# env-dep:ESCAPEnESCAPE" < $(TMPDIR)/main.d </ins>
_ => bug!(), }; <ins> let param_env = tcx.param_env(source.def_id()); </ins> for (local, decl) in body.local_decls.iter_enumerated() { // Ignore locals which are internal or not live if !live_locals.contains(local) || decl.internal { continue; } <ins> let decl_ty = tcx.normalize_erasing_regions(param_env, decl.ty); </ins> // Sanity check that typeck knows about the type of locals which are // live across a suspension point <del> if !allowed.contains(&decl.ty) && !allowed_upvars.contains(&decl.ty) { </del> <ins> if !allowed.contains(&decl_ty) && !allowed_upvars.contains(&decl_ty) { </ins> span_bug!( body.span, "Broken MIR: generator contains type {} in MIR,
<ins> // edition:2018 // #70935: Check if we do not emit snippet // with newlines which lead complex diagnostics. use std::future::Future; async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> { } fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { //~^ ERROR: future cannot be sent between threads safely async move { baz(|| async{ foo(tx.clone()); }).await; } } fn bar(_s: impl Future + Send) { } fn main() { let (tx, _rx) = std::sync::mpsc::channel(); bar(foo(tx)); } </ins>
<ins> error: future cannot be sent between threads safely --> $DIR/issue-70935-complex-spans.rs:10:45 | LL | fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { |                                             ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | = help: the trait `Sync` is not implemented for `Sender<i32>` note: future is not `Send` as this value is used across an await --> $DIR/issue-70935-complex-spans.rs:13:9 | LL | /         baz(|| async{ LL | |             foo(tx.clone()); LL | |         }).await; | |________________^ first, await occurs here, with the value maybe used later... note: the value is later dropped here --> $DIR/issue-70935-complex-spans.rs:15:17 | LL |         }).await; |                 ^ note: this has type `[closure@$DIR/issue-70935-complex-spans.rs:13:13: 15:10]` which is not `Send` --> $DIR/issue-70935-complex-spans.rs:13:13 | LL |           baz(|| async{ |  _____________^ LL | |             foo(tx.clone()); LL | |         }).await; | |_________^ error: aborting due to previous error </ins>
--> $DIR/issue-65436-raw-ptr-not-send.rs:14:9 | LL |         bar(Foo(std::ptr::null())).await; <del> |         ^^^^^^^^----------------^^^^^^^^- `std::ptr::null()` is later dropped here |         |       | |         |       has type `*const u8` which is not `Send` |         await occurs here, with `std::ptr::null()` maybe used later </del> <ins> |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first, await occurs here, with `std::ptr::null()` maybe used later... note: `std::ptr::null()` is later dropped here --> $DIR/issue-65436-raw-ptr-not-send.rs:14:41 | LL |         bar(Foo(std::ptr::null())).await; |                 ----------------        ^ |                 | |                 has type `*const u8` which is not `Send` </ins> help: consider moving this into a `let` binding to create a shorter lived borrow --> $DIR/issue-65436-raw-ptr-not-send.rs:14:13 |
} if let Some(non_sm_ty) = structural { <del> let adt_def = match non_sm_ty { traits::NonStructuralMatchTy::Adt(adt_def) => adt_def, </del> <ins> let msg = match non_sm_ty { traits::NonStructuralMatchTy::Adt(adt_def) => { let path = self.tcx().def_path_str(adt_def.did); format!( "to use a constant of type `{}` in a pattern,  `{}` must be annotated with `#[derive(PartialEq, Eq)]`", path, path, ) } traits::NonStructuralMatchTy::Dynamic => { format!("trait objects cannot be used in patterns") } </ins> traits::NonStructuralMatchTy::Param => { bug!("use of constant whose type is a parameter inside a pattern") } }; <del> let path = self.tcx().def_path_str(adt_def.did); let make_msg = || -> String { format!( "to use a constant of type `{}` in a pattern,  `{}` must be annotated with `#[derive(PartialEq, Eq)]`", path, path, ) }; </del> // double-check there even *is* a semantic `PartialEq` to dispatch to. //
if !ty_is_partial_eq { // span_fatal avoids ICE from resolution of non-existent method (rare case). <del> self.tcx().sess.span_fatal(self.span, &make_msg()); </del> <ins> self.tcx().sess.span_fatal(self.span, &msg); </ins> } else if mir_structural_match_violation { self.tcx().struct_span_lint_hir( lint::builtin::INDIRECT_STRUCTURAL_MATCH, self.id, self.span, <del> |lint| lint.build(&make_msg()).emit(), </del> <ins> |lint| lint.build(&msg).emit(), </ins> ); } else { debug!(
self.found = Some(NonStructuralMatchTy::Param); return true; // Stop visiting. } <ins> ty::Dynamic(..) => { self.found = Some(NonStructuralMatchTy::Dynamic); return true; // Stop visiting. } </ins> ty::RawPtr(..) => { // structural-match ignores substructure of // `*const _`/`*mut _`, so skip `super_visit_with`.
<ins> #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash trait A {} struct B; impl A for B {} fn test<const T: &'static dyn A>() { //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used unimplemented!() } fn main() { test::<{ &B }>(); } </ins>
<ins> warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> $DIR/issue-63322-forbid-dyn.rs:1:12 | LL | #![feature(const_generics)] |            ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter --> $DIR/issue-63322-forbid-dyn.rs:8:18 | LL | fn test<const T: &'static dyn A>() { |                  ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq` error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0741`. </ins>
See the specification for the [GitHub Tables extension][tables] for more details on the exact syntax supported. <ins> ### Task lists Task lists can be used as a checklist of items that have been completed. Example: ```md - [x] Complete task - [ ] IncComplete task ``` This will render as <ul> <li><input type="checkbox"></li> <li><input type="checkbox" checked></li> </ul> See the specification for the [task list extension] for more details. </ins> [`backtrace`]: https://docs.rs/backtrace/0.3.50/backtrace/ [commonmark markdown specification]: https://commonmark.org/ [commonmark quick reference]: https://commonmark.org/help/
[`std::env`]: https://doc.rust-lang.org/stable/std/env/index.html#functions [strikethrough]: https://github.github.com/gfm/#strikethrough-extension- [tables]: https://github.github.com/gfm/#tables-extension- <ins> [task list extension]: https://github.github.com/gfm/#task-list-items-extension- </ins>
/// Options for rendering Markdown in the main body of documentation. pub(crate) fn opts() -> Options { <del> Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES | Options::ENABLE_STRIKETHROUGH </del> <ins> Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES | Options::ENABLE_STRIKETHROUGH | Options::ENABLE_TASKLISTS </ins> } /// A subset of [`opts()`] used for rendering summaries.
<ins> // ignore-tidy-linelength // FIXME: this doesn't test as much as I'd like; ideally it would have these query too: // has task_lists/index.html '//li/input[@type="checkbox" and disabled]/following-sibling::text()' 'a' // has task_lists/index.html '//li/input[@type="checkbox"]/following-sibling::text()' 'b' // Unfortunately that requires LXML, because the built-in xml module doesn't support all of xpath. // @has task_lists/index.html '//ul/li/input[@type="checkbox"]' '' // @has task_lists/index.html '//ul/li/input[@disabled]' '' // @has task_lists/index.html '//ul/li' 'a' // @has task_lists/index.html '//ul/li' 'b' //! This tests 'task list' support, a common markdown extension. //! - [ ] a //! - [x] b </ins>
); fn is_expr_delims_necessary(inner: &ast::Expr, followed_by_block: bool) -> bool { <del> followed_by_block && match inner.kind { ExprKind::Ret(_) | ExprKind::Break(..) => true, _ => parser::contains_exterior_struct_lit(&inner), </del> <ins> // Prevent false-positives in cases like `fn x() -> u8 { ({ 0 } + 1) }` let lhs_needs_parens = { let mut innermost = inner; loop { if let ExprKind::Binary(_, lhs, _rhs) = &innermost.kind { innermost = lhs; if !rustc_ast::util::classify::expr_requires_semi_to_be_stmt(innermost) { break true; } } else { break false; } </ins> } <ins> }; lhs_needs_parens || (followed_by_block && match inner.kind { ExprKind::Ret(_) | ExprKind::Break(..) => true, _ => parser::contains_exterior_struct_lit(&inner), }) </ins> } fn emit_unused_delims_expr(
<ins> // check-pass // Make sure unused parens lint doesn't emit a false positive. // See https://github.com/rust-lang/rust/issues/71290 for details. #![deny(unused_parens)] fn x() -> u8 { ({ 0 }) + 1 } fn y() -> u8 { ({ 0 } + 1) } pub fn foo(a: bool, b: bool) -> u8 { (if a { 1 } else { 0 } + if b { 1 } else { 0 }) } pub fn bar() -> u8 { // Make sure nested expressions are handled correctly as well ({ 0 } + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) } fn main() {} </ins>
return 0; }; <ins> let will_be_emitted = |span: Span| { !span.is_dummy() && { let file = sm.lookup_source_file(span.hi()); sm.ensure_source_file_source_present(file) } }; </ins> let mut max = 0; for primary_span in msp.primary_spans() { <del> if !primary_span.is_dummy() { </del> <ins> if will_be_emitted(*primary_span) { </ins> let hi = sm.lookup_char_pos(primary_span.hi()); max = (hi.line).max(max); } } if !self.short_message { for span_label in msp.span_labels() { <del> if !span_label.span.is_dummy() { </del> <ins> if will_be_emitted(span_label.span) { </ins> let hi = sm.lookup_char_pos(span_label.span.hi()); max = (hi.line).max(max); }
<ins> // compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z ui-testing=no // only-x86_64-unknown-linux-gnu //---^ Limiting target as the above unstable flags don't play well on some environment. struct MyError; impl std::error::Error for MyError {} //~^ ERROR: `MyError` doesn't implement `std::fmt::Display` //~| ERROR: `MyError` doesn't implement `Debug` fn main() {} </ins>
<ins> error[E0277]: `MyError` doesn't implement `std::fmt::Display` --> $DIR/issue-71363.rs:6:6 | 6 | impl std::error::Error for MyError {} |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `MyError` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `std::error::Error` error[E0277]: `MyError` doesn't implement `Debug` --> $DIR/issue-71363.rs:6:6 | 6 | impl std::error::Error for MyError {} |      ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted using `{:?}` | = help: the trait `Debug` is not implemented for `MyError` = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError` note: required by a bound in `std::error::Error` help: consider annotating `MyError` with `#[derive(Debug)]` | 5 | #[derive(Debug)] | error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. </ins>
<ins> #![feature(const_generics)] #![allow(incomplete_features)] struct Test(*const usize); type PassArg = (); unsafe extern "C" fn pass(args: PassArg) { println!("Hello, world!"); } impl Test { pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { //~^ ERROR: using function pointers as const generic parameters is forbidden self.0 = Self::trampiline::<Args, IDX, FN> as _ } unsafe extern "C" fn trampiline< Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args), //~^ ERROR: using function pointers as const generic parameters is forbidden >( args: Args, ) { FN(args) } } fn main() { let x = Test(); x.call_me::<PassArg, 30, pass>() } </ins>
<ins> error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:13:61 | LL |     pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { |                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:21:19 | LL |         const FN: unsafe extern "C" fn(Args), |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors </ins>
<ins> #![feature(const_generics)] #![allow(incomplete_features)] struct Test(); fn pass() { println!("Hello, world!"); } impl Test { pub fn call_me(&self) { self.test::<pass>(); } fn test<const FN: fn()>(&self) { //~^ ERROR: using function pointers as const generic parameters is forbidden FN(); } } fn main() { let x = Test(); x.call_me() } </ins>
<ins> #![feature(const_generics)] #![allow(incomplete_features)] use std::ffi::{CStr, CString}; unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize { //~^ ERROR: using function pointers as const generic parameters is forbidden F(CStr::from_ptr(ptr)) } fn safely_do_the_thing(s: &CStr) -> usize { s.to_bytes().len() } fn main() { let baguette = CString::new("baguette").unwrap(); let ptr = baguette.as_ptr(); println!("{}", unsafe { unsafely_do_the_thing::<safely_do_the_thing>(ptr) }); } </ins>
}; } <del> let binding = if let Some(module) = module { self.resolve_ident_in_module( module, ident, ns, parent_scope, record_used, path_span, ) } else if ribs.is_none() || opt_ns.is_none() || opt_ns == Some(MacroNS) { let scopes = ScopeSet::All(ns, opt_ns.is_none()); self.early_resolve_ident_in_lexical_scope( ident, scopes, parent_scope, record_used, record_used, path_span, ) } else { let record_used_id = if record_used { crate_lint.node_id().or(Some(CRATE_NODE_ID)) } else { None }; match self.resolve_ident_in_lexical_scope( ident, ns, parent_scope, record_used_id, path_span, &ribs.unwrap()[ns], ) { // we found a locally-imported or available item/module Some(LexicalScopeBinding::Item(binding)) => Ok(binding), // we found a local variable or type param Some(LexicalScopeBinding::Res(res)) if opt_ns == Some(TypeNS) || opt_ns == Some(ValueNS) => { record_segment_res(self, res); return PathResult::NonModule(PartialRes::with_unresolved_segments( res, path.len() - 1, )); </del> <ins> enum FindBindingResult<'a> { Binding(Result<&'a NameBinding<'a>, Determinacy>), PathResult(PathResult<'a>), } let find_binding_in_ns = |this: &mut Self, ns| { let binding = if let Some(module) = module { this.resolve_ident_in_module( module, ident, ns, parent_scope, record_used, path_span, ) } else if ribs.is_none() || opt_ns.is_none() || opt_ns == Some(MacroNS) { let scopes = ScopeSet::All(ns, opt_ns.is_none()); this.early_resolve_ident_in_lexical_scope( ident, scopes, parent_scope, record_used, record_used, path_span, ) } else { let record_used_id = if record_used { crate_lint.node_id().or(Some(CRATE_NODE_ID)) } else { None }; match this.resolve_ident_in_lexical_scope( ident, ns, parent_scope, record_used_id, path_span, &ribs.unwrap()[ns], ) { // we found a locally-imported or available item/module Some(LexicalScopeBinding::Item(binding)) => Ok(binding), // we found a local variable or type param Some(LexicalScopeBinding::Res(res)) if opt_ns == Some(TypeNS) || opt_ns == Some(ValueNS) => { record_segment_res(this, res); return FindBindingResult::PathResult(PathResult::NonModule( PartialRes::with_unresolved_segments(res, path.len() - 1), )); } _ => Err(Determinacy::determined(record_used)), </ins> } <del> _ => Err(Determinacy::determined(record_used)), } </del> <ins> }; FindBindingResult::Binding(binding) }; let binding = match find_binding_in_ns(self, ns) { FindBindingResult::PathResult(x) => return x, FindBindingResult::Binding(binding) => binding, </ins> }; match binding { Ok(binding) => { if i == 1 {
} else if i == 0 { (format!("use of undeclared type or module `{}`", ident), None) } else { <del> (format!("could not find `{}` in `{}`", ident, path[i - 1].ident), None) </del> <ins> let mut msg = format!("could not find `{}` in `{}`", ident, path[i - 1].ident); if ns == TypeNS || ns == ValueNS { let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS }; if let FindBindingResult::Binding(Ok(binding)) = find_binding_in_ns(self, ns_to_try) { let mut found = |what| { msg = format!( "expected {}, found {} `{}` in `{}`", ns.descr(), what, ident, path[i - 1].ident ) }; if binding.module().is_some() { found("module") } else { match binding.res() { def::Res::<NodeId>::Def(kind, id) => found(kind.descr(id)), _ => found(ns_to_try.descr()), } } }; } (msg, None) </ins> }; return PathResult::Failed { span: ident.span,