jiebi/CodeConvo huggingface dataset:
}, } <ins> impl<'tcx> PatternKind<'tcx> { /// If this is a `PatternKind::AscribeUserType` then return the subpattern kind, otherwise /// return this pattern kind. fn with_user_type_ascription_subpattern(self) -> Self { match self { PatternKind::AscribeUserType { subpattern: Pattern { box kind, ..  }, ..  } => kind, kind => kind, } } } </ins> #[derive(Clone, Copy, Debug, PartialEq)] pub struct PatternRange<'tcx> { pub lo: ty::Const<'tcx>,
PatKind::Lit(ref value) => self.lower_lit(value), PatKind::Range(ref lo_expr, ref hi_expr, end) => { <del> match (self.lower_lit(lo_expr), self.lower_lit(hi_expr)) { (PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => { </del> <ins> match ( // Look for `PatternKind::Constant` patterns inside of any // `PatternKind::AscribeUserType` patterns. Type ascriptions can be safely // ignored for the purposes of lowering a range correctly - these are checked // elsewhere for well-formedness. self.lower_lit(lo_expr).with_user_type_ascription_subpattern(), self.lower_lit(hi_expr).with_user_type_ascription_subpattern(), ) { (PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => { </ins> use std::cmp::Ordering; let cmp = compare_const_vals( self.tcx,
<ins> // run-pass #![allow(dead_code)] trait Range { const FIRST: u8; const LAST: u8; } struct OneDigit; impl Range for OneDigit { const FIRST: u8 = 0; const LAST: u8 = 9; } struct TwoDigits; impl Range for TwoDigits { const FIRST: u8 = 10; const LAST: u8 = 99; } struct ThreeDigits; impl Range for ThreeDigits { const FIRST: u8 = 100; const LAST: u8 = 255; } fn digits(x: u8) -> u32 { match x { OneDigit::FIRST...OneDigit::LAST => 1, TwoDigits::FIRST...TwoDigits::LAST => 2, ThreeDigits::FIRST...ThreeDigits::LAST => 3, _ => unreachable!(), } } fn main() { assert_eq!(digits(100), 3); } </ins>
/// // The heap should now be empty. /// assert!(heap.is_empty()) /// ``` <ins> /// /// ## Min-heap /// /// Either `std::cmp::Reverse` or a custom `Ord` implementation can be used to /// make `BinaryHeap` a min-heap. This makes `heap.pop()` return the smallest /// value instead of the greatest one. /// /// ``` /// use std::collections::BinaryHeap; /// use std::cmp::Reverse; /// /// let mut heap = BinaryHeap::new(); /// /// // Wrap values in `Reverse` /// heap.push(Reverse(1)); /// heap.push(Reverse(5)); /// heap.push(Reverse(2)); /// /// // If we pop these scores now, they should come back in the reverse order. /// assert_eq!(heap.pop(), Some(Reverse(1))); /// assert_eq!(heap.pop(), Some(Reverse(2))); /// assert_eq!(heap.pop(), Some(Reverse(5))); /// assert_eq!(heap.pop(), None); /// ``` </ins> #[stable(feature = "rust1", since = "1.0.0")] pub struct BinaryHeap<T> { data: Vec<T>,
Box::new(MaybeUninit::uninit()) } <del> // FIXME: add a test for a bigger box. Currently broken, see // https://github.com/rust-lang/rust/issues/58201. </del> <ins> // https://github.com/rust-lang/rust/issues/58201 #[no_mangle] pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> { // CHECK-LABEL: @box_uninitialized2 // CHECK-NOT: store // CHECK-NOT: alloca // CHECK-NOT: memcpy // CHECK-NOT: memset Box::new(MaybeUninit::uninit()) } </ins> // Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above. We don't check the attributes here because we can't rely
Box::new(MaybeUninit::uninit()) } <del> // FIXME: add a test for a bigger box. Currently broken, see // https://github.com/rust-lang/rust/issues/58201. </del> <ins> // https://github.com/rust-lang/rust/issues/58201 #[no_mangle] pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> { // CHECK-LABEL: @box_uninitialized2 // CHECK-NOT: store // CHECK-NOT: alloca // CHECK-NOT: memcpy // CHECK-NOT: memset Box::new(MaybeUninit::uninit()) } </ins> // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably.
<ins> // Regression test for #62504 #![feature(const_generics)] #![allow(incomplete_features)] trait HasSize { const SIZE: usize; } impl<const X: usize> HasSize for ArrayHolder<{ X }> { const SIZE: usize = X; } struct ArrayHolder<const X: usize>([u32; X]); impl<const X: usize> ArrayHolder<{ X }> { pub const fn new() -> Self { ArrayHolder([0; Self::SIZE]) //~^ ERROR: array lengths can't depend on generic parameters } } fn main() { let mut array = ArrayHolder::new(); } </ins>
<ins> // Regression test for #58490 macro_rules! a { ( @1 $i:item ) => { a! { @2 $i } }; ( @2 $i:item ) => { $i }; } mod b { a! { @1 #[macro_export] macro_rules! b { () => () } } #[macro_export] macro_rules! b { () => () } //~^ ERROR: the name `b` is defined multiple times } mod c { #[allow(unused_imports)] use crate::b; } fn main() {} </ins>
<ins> error[E0428]: the name `b` is defined multiple times --> $DIR/issue-58490.rs:18:5 | LL |         macro_rules! b { () => () } |         -------------- previous definition of the macro `b` here ... LL |     macro_rules! b { () => () } |     ^^^^^^^^^^^^^^ `b` redefined here | = note: `b` must be defined only once in the macro namespace of this module error: aborting due to previous error For more information about this error, try `rustc --explain E0428`. </ins>
// Maybe remove `&`? hir::ExprKind::AddrOf(_, ref expr) => { if !cm.span_to_filename(expr.span).is_real() { <ins> if let Ok(code) = cm.span_to_snippet(sp) { if code.chars().next() == Some('&') { return Some(( sp, "consider removing the borrow", code[1..].to_string()), ); } } </ins> return None; } if let Ok(code) = cm.span_to_snippet(expr.span) {
error[E0308]: mismatched types --> $DIR/diverging-tuple-parts-39485.rs:8:5 | <del> LL | fn g() { |        - help: try adding a return type: `-> &_` </del> LL |     &panic!() //~ ERROR mismatched types |     ^^^^^^^^^ expected (), found reference | = note: expected type `()` found type `&_` <ins> help: try adding a return type | LL | fn g() -> &_ { |        ^^^^^ help: consider removing the borrow | LL |     panic!() //~ ERROR mismatched types |     ^^^^^^^^ </ins> error[E0308]: mismatched types --> $DIR/diverging-tuple-parts-39485.rs:12:5
<ins> error[E0308]: mismatched types --> $DIR/format-borrow.rs:2:21 | LL |     let a: String = &String::from("a"); |                     ^^^^^^^^^^^^^^^^^^ |                     | |                     expected struct `std::string::String`, found reference |                     help: consider removing the borrow: `String::from("a")` | = note: expected type `std::string::String` found type `&std::string::String` error[E0308]: mismatched types --> $DIR/format-borrow.rs:4:21 | LL |     let b: String = &format!("b"); |                     ^^^^^^^^^^^^^ |                     | |                     expected struct `std::string::String`, found reference |                     help: consider removing the borrow: `format!("b")` | = note: expected type `std::string::String` found type `&std::string::String` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>
<ins> // Regression test for #59311. The test is taken from // rust-lang/rust/issues/71546#issuecomment-620638437 // as they seem to have the same cause. // FIXME: It's not clear that this code ought to report // an error, but the regression test is here to ensure // that it does not ICE. See discussion on #74889 for details. pub trait T { fn t<F: Fn()>(&self, _: F) {} } pub fn crash<V>(v: &V) where for<'a> &'a V: T + 'static, { v.t(|| {}); //~ ERROR: higher-ranked subtype error } fn main() {} </ins>
let ident = *ident; let mut path = path.clone(); for seg in &mut path.segments { <del> seg.id = self.next_node_id(); </del> <ins> // Give the cloned segment the same resolution information // as the old one (this is needed for stability checking). let new_id = self.next_node_id(); self.resolver.clone_res(seg.id, new_id); seg.id = new_id; </ins> } let span = path.span;
// Give the segments new node-ids since they are being cloned. for seg in &mut prefix.segments { <del> seg.id = self.next_node_id(); </del> <ins> // Give the cloned segment the same resolution information // as the old one (this is needed for stability checking). let new_id = self.next_node_id(); self.resolver.clone_res(seg.id, new_id); seg.id = new_id; </ins> } // Each `use` import is an item and thus are owners of the
fn legacy_const_generic_args(&self, expr: &Expr) -> Option<Vec<usize>>; fn get_partial_res(&self, id: NodeId) -> Option<PartialRes>; fn get_import_res(&self, id: NodeId) -> PerNS<Option<Res<NodeId>>>; <ins> // Clones the resolution (if any) on 'source' and applies it // to 'target'. Used when desugaring a `UseTreeKind::Nested` to // multiple `UseTreeKind::Simple`s fn clone_res(&mut self, source: NodeId, target: NodeId); </ins> fn get_label_res(&self, id: NodeId) -> Option<NodeId>; fn get_lifetime_res(&self, id: NodeId) -> Option<LifetimeRes>; fn take_extra_lifetime_params(&mut self, id: NodeId) -> Vec<(Ident, NodeId, LifetimeRes)>;
None } <ins> fn clone_res(&mut self, source: NodeId, target: NodeId) { if let Some(res) = self.partial_res_map.get(&source) { self.partial_res_map.insert(target, *res); } } </ins> /// Obtains resolution for a `NodeId` with a single resolution. fn get_partial_res(&self, id: NodeId) -> Option<PartialRes> { self.partial_res_map.get(&id).copied()
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'unstable_test_feature' <ins> --> $DIR/lint-output-format.rs:7:26 | LL | use lint_output_format::{foo, bar}; |                          ^^^ | = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'unstable_test_feature' </ins> --> $DIR/lint-output-format.rs:7:31 | LL | use lint_output_format::{foo, bar};
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'unstable_test_feature' <del> --> $DIR/lint-output-format.rs:11:14 </del> <ins> --> $DIR/lint-output-format.rs:12:14 </ins> | LL |     let _y = bar(); |              ^^^ | = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable <del> error: aborting due to 3 previous errors </del> <ins> error: aborting due to 4 previous errors </ins> For more information about this error, try `rustc --explain E0658`.
impl stable_in_unstable_std::old_stable_module::OldTrait for LocalType {} } <ins> mod isolated6 { use stable_in_unstable_core::new_unstable_module::{OldTrait}; //~ ERROR use of unstable library feature 'unstable_test_feature' } mod isolated7 { use stable_in_unstable_core::new_unstable_module::*; //~ ERROR use of unstable library feature 'unstable_test_feature' } </ins>
= note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable <del> error: aborting due to 4 previous errors </del> <ins> error[E0658]: use of unstable library feature 'unstable_test_feature' --> $DIR/stable-in-unstable.rs:49:56 | LL |     use stable_in_unstable_core::new_unstable_module::{OldTrait}; |                                                        ^^^^^^^^ | = note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable error[E0658]: use of unstable library feature 'unstable_test_feature' --> $DIR/stable-in-unstable.rs:53:9 | LL |     use stable_in_unstable_core::new_unstable_module::*; |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #1 <https://github.com/rust-lang/rust/issues/1> for more information = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable error: aborting due to 6 previous errors </ins> For more information about this error, try `rustc --explain E0658`.
/// Returns the creation time listed in this metadata. /// <del> /// The returned value corresponds to the `birthtime` field of `stat` on /// Unix platforms and the `ftCreationTime` field on Windows platforms. </del> <ins> /// The returned value corresponds to the `btime` field of `statx` on /// Linux kernel starting from to 4.11, the `birthtime` field of `stat` on other /// Unix platforms, and the `ftCreationTime` field on Windows platforms. </ins> /// /// # Errors /// /// This field may not be available on all platforms, and will return an <del> /// `Err` on platforms where it is not available. </del> <ins> /// `Err` on platforms or filesystems where it is not available. </ins> /// /// # Examples ///
check!(a.created()); check!(b.created()); } <ins> if cfg!(target_os = "linux") { // Not always available match (a.created(), b.created()) { (Ok(t1), Ok(t2)) => assert!(t1 <= t2), (Err(e1), Err(e2)) if e1.kind() == ErrorKind::Other && e2.kind() == ErrorKind::Other => {} (a, b) => panic!( "creation time must be always supported or not supported: {:?} {:?}", a, b, ), } } </ins> } }
#[derive(Debug)] pub struct DirBuilder { mode: mode_t } <ins> cfg_has_statx! {{ impl FileAttr { fn from_stat64(stat: stat64) -> Self { Self { stat, statx_extra_fields: None } } } } else { impl FileAttr { fn from_stat64(stat: stat64) -> Self { Self { stat } } } }} </ins> impl FileAttr { pub fn size(&self) -> u64 { self.stat.st_size as u64 } pub fn perm(&self) -> FilePermissions {
target_os = "macos", target_os = "ios")))] pub fn created(&self) -> io::Result<SystemTime> { <ins> cfg_has_statx! { if let Some(ext) = &self.statx_extra_fields { return if (ext.stx_mask & libc::STATX_BTIME) != 0 { Ok(SystemTime::from(libc::timespec { tv_sec: ext.stx_btime.tv_sec as libc::time_t, tv_nsec: ext.stx_btime.tv_nsec as _, })) } else { Err(io::Error::new( io::ErrorKind::Other, "creation time is not available for the filesystem", )) }; } } </ins> Err(io::Error::new(io::ErrorKind::Other, "creation time is not available on this platform  currently"))
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "android"))] pub fn metadata(&self) -> io::Result<FileAttr> { <del> let fd = cvt(unsafe {dirfd(self.dir.inner.dirp.0)})?; </del> <ins> let fd = cvt(unsafe { dirfd(self.dir.inner.dirp.0) })?; let name = self.entry.d_name.as_ptr(); cfg_has_statx! { if let Some(ret) = unsafe { try_statx( fd, name, libc::AT_SYMLINK_NOFOLLOW | libc::AT_STATX_SYNC_AS_STAT, libc::STATX_ALL, ) } { return ret; } } </ins> let mut stat: stat64 = unsafe { mem::zeroed() }; cvt(unsafe { <del> fstatat64(fd, self.entry.d_name.as_ptr(), &mut stat, libc::AT_SYMLINK_NOFOLLOW) </del> <ins> fstatat64(fd, name, &mut stat, libc::AT_SYMLINK_NOFOLLOW) </ins> })?; <del> Ok(FileAttr { stat }) </del> <ins> Ok(FileAttr::from_stat64(stat)) </ins> } #[cfg(not(any(target_os = "linux", target_os = "emscripten", target_os = "android")))]
} pub fn file_attr(&self) -> io::Result<FileAttr> { <ins> let fd = self.0.raw(); cfg_has_statx! { if let Some(ret) = unsafe { try_statx( fd, b"0" as *const _ as *const libc::c_char, libc::AT_EMPTY_PATH | libc::AT_STATX_SYNC_AS_STAT, libc::STATX_ALL, ) } { return ret; } } </ins> let mut stat: stat64 = unsafe { mem::zeroed() }; cvt(unsafe { <del> fstat64(self.0.raw(), &mut stat) </del> <ins> fstat64(fd, &mut stat) </ins> })?; <del> Ok(FileAttr { stat }) </del> <ins> Ok(FileAttr::from_stat64(stat)) </ins> } pub fn fsync(&self) -> io::Result<()> {
pub fn stat(p: &Path) -> io::Result<FileAttr> { let p = cstr(p)?; <ins> cfg_has_statx! { if let Some(ret) = unsafe { try_statx( libc::AT_FDCWD, p.as_ptr(), libc::AT_STATX_SYNC_AS_STAT, libc::STATX_ALL, ) } { return ret; } } </ins> let mut stat: stat64 = unsafe { mem::zeroed() }; cvt(unsafe { stat64(p.as_ptr(), &mut stat) })?; <del> Ok(FileAttr { stat }) </del> <ins> Ok(FileAttr::from_stat64(stat)) </ins> } pub fn lstat(p: &Path) -> io::Result<FileAttr> { let p = cstr(p)?; <ins> cfg_has_statx! { if let Some(ret) = unsafe { try_statx( libc::AT_FDCWD, p.as_ptr(), libc::AT_SYMLINK_NOFOLLOW | libc::AT_STATX_SYNC_AS_STAT, libc::STATX_ALL, ) } { return ret; } } </ins> let mut stat: stat64 = unsafe { mem::zeroed() }; cvt(unsafe { lstat64(p.as_ptr(), &mut stat) })?; <del> Ok(FileAttr { stat }) </del> <ins> Ok(FileAttr::from_stat64(stat)) </ins> } pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
borrow_region: RegionVid, outlived_region: RegionVid, ) -> (ConstraintCategory, bool, Span, Option<RegionName>) { <del> let (category, from_closure, span) = self.best_blame_constraint(mir, borrow_region, |r| r == outlived_region); </del> <ins> let (category, from_closure, span) = self.best_blame_constraint( mir, borrow_region, |r| self.provides_universal_region(r, borrow_region, outlived_region) ); </ins> let outlived_fr_name = self.give_region_a_name(infcx, mir, upvars, mir_def_id, outlived_region, &mut 1); (category, from_closure, span, outlived_fr_name)
<ins> // Test that we handle the case when a local variable is borrowed for `'static` // due to an outlives constraint involving a region in an incompatible universe pub trait Outlives<'this> {} impl<'this, T> Outlives<'this> for T where T: 'this {} trait Reference { type AssociatedType; } impl<'a, T: 'a> Reference for &'a T { type AssociatedType = &'a (); } fn assert_static_via_hrtb<G>(_: G) where for<'a> G: Outlives<'a> {} fn assert_static_via_hrtb_with_assoc_type<T>(_: &'_ T) where for<'a> &'a T: Reference<AssociatedType = &'a ()>, {} fn main() { let local = 0; assert_static_via_hrtb(&local); //~ ERROR `local` does not live long enough assert_static_via_hrtb_with_assoc_type(&&local); //~ ERROR `local` does not live long enough } </ins>
<ins> error[E0597]: `local` does not live long enough --> $DIR/local-outlives-static-via-hrtb.rs:24:28 | LL |     assert_static_via_hrtb(&local); |     -----------------------^^^^^^- |     |                      | |     |                      borrowed value does not live long enough |     argument requires that `local` is borrowed for `'static` LL |     assert_static_via_hrtb_with_assoc_type(&&local); LL | } | - `local` dropped here while still borrowed error[E0597]: `local` does not live long enough --> $DIR/local-outlives-static-via-hrtb.rs:25:45 | LL |     assert_static_via_hrtb_with_assoc_type(&&local); |     ----------------------------------------^^^^^^- |     |                                       | |     |                                       borrowed value does not live long enough |     argument requires that `local` is borrowed for `'static` LL | } | - `local` dropped here while still borrowed error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0597`. </ins>
dox[code_block.code].to_owned(), ); <del> let has_errors = { let mut has_errors = false; </del> <ins> let validation_status = { let mut has_syntax_errors = false; let mut only_whitespace = true; // even if there is a syntax error, we need to run the lexer over the whole file </ins> let mut lexer = Lexer::new(&sess, source_file, None); loop  { match lexer.next_token().kind { token::Eof => break, <del> token::Unknown(..) => has_errors = true, _ => (), </del> <ins> token::Whitespace => (), token::Unknown(..) => has_syntax_errors = true, _ => only_whitespace = false, </ins> } } <del> has_errors </del> <ins> if has_syntax_errors { Some(CodeBlockInvalid::SyntaxError) } else if only_whitespace { Some(CodeBlockInvalid::Empty) } else { None } </ins> }; <del> if has_errors { </del> <ins> if let Some(code_block_invalid) = validation_status { </ins> let mut diag = if let Some(sp) = super::source_span_for_markdown_range(self.cx, &dox, &code_block.range, &item.attrs) { <del> let mut diag = self .cx .sess() .struct_span_warn(sp, "could not parse code block as Rust code"); </del> <ins> let warning_message = match code_block_invalid { CodeBlockInvalid::SyntaxError => "could not parse code block as Rust code", CodeBlockInvalid::Empty => "Rust code block is empty", }; let mut diag = self.cx.sess().struct_span_warn(sp, warning_message); </ins> if code_block.syntax.is_none() && code_block.is_fenced { let sp = sp.from_inner(InnerSpan::new(0, 3));
| = help: mark blocks that do not contain Rust code as text: ```text <ins> warning: Rust code block is empty --> $DIR/invalid-syntax.rs:68:5 | LL |   /// ```rust |  _____^ LL | | /// ``` | |_______^ warning: Rust code block is empty --> $DIR/invalid-syntax.rs:72:5 | LL |   /// ``` |  _____^ LL | | /// LL | | /// LL | | /// ``` | |_______^ help: mark blocks that do not contain Rust code as text | LL | /// ```text |     ^^^^^^^ </ins> error: unknown start of token:  --> <rustdoc-highlighting>:1:1 |
return } <del> // For the wasm32 target statics with #[link_section] are placed into custom </del> <ins> // For the wasm32 target statics with `#[link_section]` are placed into custom </ins> // sections of the final output file, but this isn't link custom sections of // other executable formats. Namely we can only embed a list of bytes, // nothing with pointers to anything else or relocations. If any relocation // show up, reject them here. <ins> // `#[link_section]` may contain arbitrary, or even undefined bytes, but it is // the consumer's responsibility to ensure all bytes that have been read // have defined values. </ins> let instance = ty::Instance::mono(tcx, id); let cid = GlobalId { instance,
/// When using a future, you generally won't call `poll` directly, but instead /// `await!` the value. #[doc(spotlight)] <del> #[must_use = "futures do nothing unless polled"] </del> <ins> #[must_use = "futures do nothing unless you `.await` or poll them"] </ins> #[stable(feature = "futures_api", since = "1.36.0")] pub trait Future { /// The type of value produced on completion.
use rustc::hir::def::{Res, DefKind}; use rustc::hir::def_id::DefId; use rustc::lint; <del> use rustc::ty; </del> <ins> use rustc::ty::{self, Ty}; </ins> use rustc::ty::adjustment; use rustc_data_structures::fx::FxHashMap; use lint::{LateContext, EarlyContext, LintContext, LintArray};
return; } <del> let t = cx.tables.expr_ty(&expr); let type_permits_lack_of_use = if t.is_unit() || cx.tcx.is_ty_uninhabited_from( cx.tcx.hir().get_module_parent_by_hir_id(expr.hir_id), t) { true } else { match t.sty { ty::Adt(def, _) => check_must_use(cx, def.did, s.span, "", ""), ty::Opaque(def, _) => { let mut must_use = false; for (predicate, _) in &cx.tcx.predicates_of(def).predicates { if let ty::Predicate::Trait(ref poly_trait_predicate) = predicate { let trait_ref = poly_trait_predicate.skip_binder().trait_ref; if check_must_use(cx, trait_ref.def_id, s.span, "implementer of ", "") { must_use = true; break; } } } must_use } ty::Dynamic(binder, _) => { let mut must_use = false; for predicate in binder.skip_binder().iter() { if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate { if check_must_use(cx, trait_ref.def_id, s.span, "", " trait object") { must_use = true; break; } } } must_use } _ => false, } }; </del> <ins> let ty = cx.tables.expr_ty(&expr); let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, ""); </ins> let mut fn_warned = false; let mut op_warned = false;
_ => None }; if let Some(def_id) = maybe_def_id { <del> fn_warned = check_must_use(cx, def_id, s.span, "return value of ", ""); </del> <ins> fn_warned = check_must_use_def(cx, def_id, s.span, "return value of ", ""); </ins> } else if type_permits_lack_of_use { // We don't warn about unused unit or uninhabited types. // (See https://github.com/rust-lang/rust/issues/43806 for details.)