Auto merge of #110295 - matthiaskrgr:rollup-xas29a1, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #109036 (Fix diff option conflict in UI test)
 - #110193 (Check for body owner fallibly in error reporting)
 - #110233 (Make rust-intrinsic ABI unwindable)
 - #110259 (Added diagnostic for pin! macro in addition to Box::pin if Unpin isn't implemented)
 - #110265 (Automatically update the LLVM submodule for musl target (and other places))
 - #110277 (dead-code-lint: de-dup multiple unused assoc functions)
 - #110283 (Only emit alignment checks if we have a panic_impl)
 - #110291 (Implement `Copy` for `LocationDetail`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-04-13 20:34:12 +00:00
commit a41fc00eaf
41 changed files with 580 additions and 103 deletions

View File

@ -77,7 +77,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
line: u32,
col: u32,
) -> MPlaceTy<'tcx, M::Provenance> {
let loc_details = &self.tcx.sess.opts.unstable_opts.location_detail;
let loc_details = self.tcx.sess.opts.unstable_opts.location_detail;
// This can fail if rustc runs out of memory right here. Trying to emit an error would be
// pointless, since that would require allocating more memory than these short strings.
let file = if loc_details.file {

View File

@ -1226,10 +1226,11 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
| AvrNonBlockingInterrupt
| CCmseNonSecureCall
| Wasm
| RustIntrinsic
| PlatformIntrinsic
| Unadjusted => false,
Rust | RustCall | RustCold => tcx.sess.panic_strategy() == PanicStrategy::Unwind,
Rust | RustCall | RustCold | RustIntrinsic => {
tcx.sess.panic_strategy() == PanicStrategy::Unwind
}
}
}

View File

@ -1,5 +1,6 @@
use crate::MirPass;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
use rustc_index::vec::IndexVec;
use rustc_middle::mir::*;
use rustc_middle::mir::{
@ -17,6 +18,12 @@ impl<'tcx> MirPass<'tcx> for CheckAlignment {
}
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// This pass emits new panics. If for whatever reason we do not have a panic
// implementation, running this pass may cause otherwise-valid code to not compile.
if tcx.lang_items().get(LangItem::PanicImpl).is_none() {
return;
}
let basic_blocks = body.basic_blocks.as_mut();
let local_decls = &mut body.local_decls;

View File

@ -700,6 +700,13 @@ impl<'tcx> DeadVisitor<'tcx> {
.collect();
let descr = tcx.def_descr(first_id.to_def_id());
// `impl` blocks are "batched" and (unlike other batching) might
// contain different kinds of associated items.
let descr = if dead_codes.iter().any(|did| tcx.def_descr(did.to_def_id()) != descr) {
"associated item"
} else {
descr
};
let num = dead_codes.len();
let multiple = num > 6;
let name_list = names.into();
@ -712,12 +719,12 @@ impl<'tcx> DeadVisitor<'tcx> {
let parent_info = if let Some(parent_item) = parent_item {
let parent_descr = tcx.def_descr(parent_item.to_def_id());
Some(ParentInfo {
num,
descr,
parent_descr,
span: tcx.def_ident_span(parent_item).unwrap(),
})
let span = if let DefKind::Impl { .. } = tcx.def_kind(parent_item) {
tcx.def_span(parent_item)
} else {
tcx.def_ident_span(parent_item).unwrap()
};
Some(ParentInfo { num, descr, parent_descr, span })
} else {
None
};
@ -800,16 +807,7 @@ impl<'tcx> DeadVisitor<'tcx> {
}
fn check_definition(&mut self, def_id: LocalDefId) {
if self.live_symbols.contains(&def_id) {
return;
}
if has_allow_dead_code_or_lang_attr(self.tcx, def_id) {
return;
}
let Some(name) = self.tcx.opt_item_name(def_id.to_def_id()) else {
return
};
if name.as_str().starts_with('_') {
if self.is_live_code(def_id) {
return;
}
match self.tcx.def_kind(def_id) {
@ -827,6 +825,18 @@ impl<'tcx> DeadVisitor<'tcx> {
_ => {}
}
}
fn is_live_code(&self, def_id: LocalDefId) -> bool {
// if we cannot get a name for the item, then we just assume that it is
// live. I mean, we can't really emit a lint.
let Some(name) = self.tcx.opt_item_name(def_id.to_def_id()) else {
return true;
};
self.live_symbols.contains(&def_id)
|| has_allow_dead_code_or_lang_attr(self.tcx, def_id)
|| name.as_str().starts_with('_')
}
}
fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
@ -836,6 +846,22 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
let module_items = tcx.hir_module_items(module);
for item in module_items.items() {
if let hir::ItemKind::Impl(impl_item) = tcx.hir().item(item).kind {
let mut dead_items = Vec::new();
for item in impl_item.items {
let did = item.id.owner_id.def_id;
if !visitor.is_live_code(did) {
dead_items.push(did)
}
}
visitor.warn_multiple_dead_codes(
&dead_items,
"used",
Some(item.owner_id.def_id),
false,
);
}
if !live_symbols.contains(&item.owner_id.def_id) {
let parent = tcx.local_parent(item.owner_id.def_id);
if parent != module && !live_symbols.contains(&parent) {
@ -900,10 +926,6 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalDefId) {
}
}
for impl_item in module_items.impl_items() {
visitor.check_definition(impl_item.owner_id.def_id);
}
for foreign_item in module_items.foreign_items() {
visitor.check_definition(foreign_item.owner_id.def_id);
}

View File

@ -222,7 +222,7 @@ impl LinkerPluginLto {
}
/// The different settings that can be enabled via the `-Z location-detail` flag.
#[derive(Clone, PartialEq, Hash, Debug)]
#[derive(Copy, Clone, PartialEq, Hash, Debug)]
pub struct LocationDetail {
pub file: bool,
pub line: bool,

View File

@ -2396,8 +2396,8 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}
if let Some(ty::subst::GenericArgKind::Type(_)) = subst.map(|subst| subst.unpack())
&& let Some(body_id) = self.tcx.hir().maybe_body_owned_by(obligation.cause.body_id)
{
let body_id = self.tcx.hir().body_owned_by(obligation.cause.body_id);
let mut expr_finder = FindExprBySpan::new(span);
expr_finder.visit_expr(&self.tcx.hir().body(body_id).value);

View File

@ -615,12 +615,15 @@ impl<'f> Drop for VaListImpl<'f> {
extern "rust-intrinsic" {
/// Destroy the arglist `ap` after initialization with `va_start` or
/// `va_copy`.
#[rustc_nounwind]
fn va_end(ap: &mut VaListImpl<'_>);
/// Copies the current location of arglist `src` to the arglist `dst`.
#[rustc_nounwind]
fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>);
/// Loads an argument of type `T` from the `va_list` `ap` and increment the
/// argument `ap` points to.
#[rustc_nounwind]
fn va_arg<T: sealed_trait::VaArgSafe>(ap: &mut VaListImpl<'_>) -> T;
}

File diff suppressed because it is too large Load Diff

View File

@ -823,7 +823,7 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
/// [`pin` module]: crate::pin
#[stable(feature = "pin", since = "1.33.0")]
#[rustc_on_unimplemented(
note = "consider using `Box::pin`",
note = "consider using the `pin!` macro\nconsider using `Box::pin` if you need to access the pinned value outside of the current scope",
message = "`{Self}` cannot be unpinned"
)]
#[lang = "unpin"]

View File

@ -1371,6 +1371,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
// as `intrinsics::copy_nonoverlapping` is a wrapper function.
extern "rust-intrinsic" {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[rustc_nounwind]
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
}

View File

@ -498,6 +498,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
// This function cannot be marked as `unsafe` because `intrinsics::r#try`
// expects normal function pointers.
#[inline]
#[rustc_nounwind] // `intrinsic::r#try` requires catch fn to be nounwind
fn do_catch<F: FnOnce() -> R, R>(data: *mut u8, payload: *mut u8) {
// SAFETY: this is the responsibility of the caller, see above.
//

View File

@ -895,6 +895,8 @@ impl Step for Src {
/// Creates the `rust-src` installer component
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
builder.update_submodule(&Path::new("src/llvm-project"));
let tarball = Tarball::new_targetless(builder, "rust-src");
// A lot of tools expect the rust-src component to be entirely in this directory, so if you

View File

@ -1087,6 +1087,8 @@ impl Step for CrtBeginEnd {
/// Build crtbegin.o/crtend.o for musl target.
fn run(self, builder: &Builder<'_>) -> Self::Output {
builder.update_submodule(&Path::new("src/llvm-project"));
let out_dir = builder.native_dir(self.target).join("crt");
if builder.config.dry_run() {
@ -1153,6 +1155,8 @@ impl Step for Libunwind {
/// Build linunwind.a
fn run(self, builder: &Builder<'_>) -> Self::Output {
builder.update_submodule(&Path::new("src/llvm-project"));
if builder.config.dry_run() {
return PathBuf::new();
}

View File

@ -0,0 +1,25 @@
// MIR for `main` after AbortUnwindingCalls
fn main() -> () {
let mut _0: (); // return place in scope 0 at $DIR/issue_104451_unwindable_intrinsics.rs:+0:11: +0:11
let mut _1: !; // in scope 0 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:9: +2:62
let mut _2: (); // in scope 0 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:45: +2:47
scope 1 {
}
bb0: {
StorageLive(_1); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:9: +2:62
StorageLive(_2); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:45: +2:47
_2 = (); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:45: +2:47
_1 = const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>(move _2, ow_ct, ow_ct); // scope 1 at $DIR/issue_104451_unwindable_intrinsics.rs:+2:9: +2:62
// mir::Constant
// + span: $DIR/issue_104451_unwindable_intrinsics.rs:8:9: 8:44
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn((), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}) -> ! {const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>}, val: Value(<ZST>) }
// mir::Constant
// + span: $DIR/issue_104451_unwindable_intrinsics.rs:8:49: 8:54
// + literal: Const { ty: fn() -> ! {ow_ct}, val: Value(<ZST>) }
// mir::Constant
// + span: $DIR/issue_104451_unwindable_intrinsics.rs:8:56: 8:61
// + literal: Const { ty: fn() -> ! {ow_ct}, val: Value(<ZST>) }
}
}

View File

@ -0,0 +1,14 @@
// Check that `UnwindAction::Unreachable` is not generated for unwindable intrinsics.
// ignore-wasm32 compiled with panic=abort by default
#![feature(core_intrinsics)]
// EMIT_MIR issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir
fn main() {
unsafe {
core::intrinsics::const_eval_select((), ow_ct, ow_ct)
}
}
const fn ow_ct() -> ! {
panic!();
}

View File

@ -11,7 +11,7 @@
StorageLive(_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38
- _1 = std::intrinsics::assume(const true) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:105:9: 105:32
- // + span: $DIR/lower_intrinsics.rs:106:9: 106:32
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(bool) {std::intrinsics::assume}, val: Value(<ZST>) }
+ assume(const true); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38

View File

@ -49,7 +49,7 @@
StorageDead(_9); // scope 3 at $DIR/lower_intrinsics.rs:+4:90: +4:91
- _3 = copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:98:9: 98:28
- // + span: $DIR/lower_intrinsics.rs:99:9: 99:28
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, *mut i32, usize) {copy_nonoverlapping::<i32>}, val: Value(<ZST>) }
+ copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95
+ goto -> bb1; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95

View File

@ -24,7 +24,7 @@
_4 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:55: +2:56
- _3 = option_payload_ptr::<usize>(move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:132:18: 132:54
- // + span: $DIR/lower_intrinsics.rs:133:18: 133:54
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<usize>) -> *const usize {option_payload_ptr::<usize>}, val: Value(<ZST>) }
+ _3 = &raw const (((*_4) as Some).0: usize); // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57
@ -37,7 +37,7 @@
_6 = &raw const (*_2); // scope 2 at $DIR/lower_intrinsics.rs:+3:55: +3:56
- _5 = option_payload_ptr::<String>(move _6) -> [return: bb2, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:133:18: 133:54
- // + span: $DIR/lower_intrinsics.rs:134:18: 134:54
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<String>) -> *const String {option_payload_ptr::<String>}, val: Value(<ZST>) }
+ _5 = &raw const (((*_6) as Some).0: std::string::String); // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57
+ goto -> bb2; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57

View File

@ -13,7 +13,7 @@
_2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47
- _0 = read_via_copy::<i32>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:118:14: 118:45
- // + span: $DIR/lower_intrinsics.rs:119:14: 119:45
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32) -> i32 {read_via_copy::<i32>}, val: Value(<ZST>) }
+ _0 = (*_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
+ goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48

View File

@ -13,7 +13,7 @@
_2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47
- _0 = read_via_copy::<Never>(move _2) -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:123:14: 123:45
- // + span: $DIR/lower_intrinsics.rs:124:14: 124:45
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Never) -> Never {read_via_copy::<Never>}, val: Value(<ZST>) }
+ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48
}

View File

@ -1,7 +1,7 @@
// unit-test: LowerIntrinsics
// ignore-wasm32 compiled with panic=abort by default
#![feature(core_intrinsics, intrinsics)]
#![feature(core_intrinsics, intrinsics, rustc_attrs)]
#![crate_type = "lib"]
// EMIT_MIR lower_intrinsics.wrapping.LowerIntrinsics.diff
@ -87,6 +87,7 @@ pub fn discriminant<T>(t: T) {
extern "rust-intrinsic" {
// Cannot use `std::intrinsics::copy_nonoverlapping` as that is a wrapper function
#[rustc_nounwind]
fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
}

View File

@ -32,7 +32,7 @@
_5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54
- _3 = add_with_overflow::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:111:14: 111:49
- // + span: $DIR/lower_intrinsics.rs:112:14: 112:49
- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {add_with_overflow::<i32>}, val: Value(<ZST>) }
+ _3 = CheckedAdd(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55
+ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55
@ -48,7 +48,7 @@
_8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:53: +2:54
- _6 = sub_with_overflow::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:112:14: 112:49
- // + span: $DIR/lower_intrinsics.rs:113:14: 113:49
- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {sub_with_overflow::<i32>}, val: Value(<ZST>) }
+ _6 = CheckedSub(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55
+ goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55
@ -64,7 +64,7 @@
_11 = _2; // scope 2 at $DIR/lower_intrinsics.rs:+3:53: +3:54
- _9 = mul_with_overflow::<i32>(move _10, move _11) -> [return: bb3, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55
- // mir::Constant
- // + span: $DIR/lower_intrinsics.rs:113:14: 113:49
- // + span: $DIR/lower_intrinsics.rs:114:14: 114:49
- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {mul_with_overflow::<i32>}, val: Value(<ZST>) }
+ _9 = CheckedMul(move _10, move _11); // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55
+ goto -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55

View File

@ -14,7 +14,7 @@ all:
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR)
# Check if everything exactly same
$(DIFF) -r -q $(OUTPUT_DIR) $(TMP_OUTPUT_DIR)
$(DIFF) -r $(OUTPUT_DIR) $(TMP_OUTPUT_DIR)
# Generate json doc on the same output
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR) -Z unstable-options --output-format json
@ -29,4 +29,4 @@ all:
$(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR) -Z unstable-options --output-format json
# Check if all docs(including both json and html formats) are still the same after multiple compilations
$(DIFF) -r -q $(OUTPUT_DIR) $(TMP_OUTPUT_DIR)
$(DIFF) -r $(OUTPUT_DIR) $(TMP_OUTPUT_DIR)

View File

@ -1,6 +1,8 @@
error: associated constant `BAR` is never used
--> $DIR/associated-const-dead-code.rs:6:11
|
LL | impl MyFoo {
| ---------- associated constant in this implementation
LL | const BAR: u32 = 1;
| ^^^
|

View File

@ -6,7 +6,8 @@ LL | Pin::new(&mut self.sleep).poll(cx)
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `Sleep`
--> $DIR/pin-needed-to-poll-2.rs:8:8
|

View File

@ -6,7 +6,8 @@ LL | assert_unpin(generator);
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required by a bound in `assert_unpin`
--> $DIR/static-not-unpin.rs:7:20
|

View File

@ -11,8 +11,8 @@ struct Foo {
struct Bar;
impl Bar {
fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used
pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used
fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code]
pub fn b(&self) -> i32 { 6 }
}
pub(crate) struct Foo1 {
@ -23,8 +23,8 @@ pub(crate) struct Foo1 {
pub(crate) struct Bar1;
impl Bar1 {
fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used
pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used
fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code]
pub fn b(&self) -> i32 { 6 }
}
pub(crate) struct Foo2 {
@ -35,8 +35,8 @@ pub(crate) struct Foo2 {
pub(crate) struct Bar2;
impl Bar2 {
fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used
pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used
fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code]
pub fn b(&self) -> i32 { 6 }
}

View File

@ -14,6 +14,16 @@ note: the lint level is defined here
LL | #![warn(dead_code)]
| ^^^^^^^^^
warning: methods `a` and `b` are never used
--> $DIR/issue-85255.rs:14:8
|
LL | impl Bar {
| -------- methods in this implementation
LL | fn a(&self) -> i32 { 5 }
| ^
LL | pub fn b(&self) -> i32 { 6 }
| ^
warning: fields `a` and `b` are never read
--> $DIR/issue-85255.rs:19:5
|
@ -24,6 +34,16 @@ LL | a: i32,
LL | pub b: i32,
| ^
warning: methods `a` and `b` are never used
--> $DIR/issue-85255.rs:26:8
|
LL | impl Bar1 {
| --------- methods in this implementation
LL | fn a(&self) -> i32 { 5 }
| ^
LL | pub fn b(&self) -> i32 { 6 }
| ^
warning: fields `a` and `b` are never read
--> $DIR/issue-85255.rs:31:5
|
@ -34,41 +54,15 @@ LL | a: i32,
LL | pub b: i32,
| ^
warning: method `a` is never used
--> $DIR/issue-85255.rs:14:8
|
LL | fn a(&self) -> i32 { 5 }
| ^
warning: method `b` is never used
--> $DIR/issue-85255.rs:15:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^
warning: method `a` is never used
--> $DIR/issue-85255.rs:26:8
|
LL | fn a(&self) -> i32 { 5 }
| ^
warning: method `b` is never used
--> $DIR/issue-85255.rs:27:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^
warning: method `a` is never used
warning: methods `a` and `b` are never used
--> $DIR/issue-85255.rs:38:8
|
LL | impl Bar2 {
| --------- methods in this implementation
LL | fn a(&self) -> i32 { 5 }
| ^
warning: method `b` is never used
--> $DIR/issue-85255.rs:39:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^
warning: 9 warnings emitted
warning: 6 warnings emitted

View File

@ -10,6 +10,14 @@ note: the lint level is defined here
LL | #![deny(dead_code)]
| ^^^^^^^^^
error: method `foo` is never used
--> $DIR/lint-dead-code-3.rs:16:8
|
LL | impl Foo {
| -------- method in this implementation
LL | fn foo(&self) {
| ^^^
error: function `bar` is never used
--> $DIR/lint-dead-code-3.rs:21:4
|
@ -34,12 +42,6 @@ error: function `blah` is never used
LL | fn blah() {}
| ^^^^
error: method `foo` is never used
--> $DIR/lint-dead-code-3.rs:16:8
|
LL | fn foo(&self) {
| ^^^
error: function `free` is never used
--> $DIR/lint-dead-code-3.rs:62:8
|

View File

@ -2,17 +2,16 @@
struct UnusedStruct; //~ ERROR struct `UnusedStruct` is never constructed
impl UnusedStruct {
fn unused_impl_fn_1() { //~ ERROR associated function `unused_impl_fn_1` is never used
fn unused_impl_fn_1() {
//~^ ERROR associated functions `unused_impl_fn_1`, `unused_impl_fn_2`, and `unused_impl_fn_3` are never used [dead_code]
println!("blah");
}
fn unused_impl_fn_2(var: i32) { //~ ERROR associated function `unused_impl_fn_2` is never used
fn unused_impl_fn_2(var: i32) {
println!("foo {}", var);
}
fn unused_impl_fn_3( //~ ERROR associated function `unused_impl_fn_3` is never used
var: i32,
) {
fn unused_impl_fn_3(var: i32) {
println!("bar {}", var);
}
}

View File

@ -10,23 +10,19 @@ note: the lint level is defined here
LL | #![deny(dead_code)]
| ^^^^^^^^^
error: associated function `unused_impl_fn_1` is never used
error: associated functions `unused_impl_fn_1`, `unused_impl_fn_2`, and `unused_impl_fn_3` are never used
--> $DIR/lint-dead-code-6.rs:5:8
|
LL | impl UnusedStruct {
| ----------------- associated functions in this implementation
LL | fn unused_impl_fn_1() {
| ^^^^^^^^^^^^^^^^
error: associated function `unused_impl_fn_2` is never used
--> $DIR/lint-dead-code-6.rs:9:8
|
...
LL | fn unused_impl_fn_2(var: i32) {
| ^^^^^^^^^^^^^^^^
error: associated function `unused_impl_fn_3` is never used
--> $DIR/lint-dead-code-6.rs:13:8
|
LL | fn unused_impl_fn_3(
...
LL | fn unused_impl_fn_3(var: i32) {
| ^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
error: aborting due to 2 previous errors

View File

@ -0,0 +1,35 @@
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
#![deny(unused)]
struct Foo;
impl Foo {
fn one() {}
//~^ ERROR associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used [dead_code]
fn two(&self) {}
// seperation between items
// ...
// ...
fn used() {}
const CONSTANT: usize = 5;
// more seperation
// ...
// ...
type Type = usize;
fn three(&self) {
Foo::one();
// ...
}
}
fn main() {
Foo::used();
}

View File

@ -0,0 +1,29 @@
error: associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used
--> $DIR/unused-assoc-fns.rs:8:8
|
LL | impl Foo {
| -------- associated items in this implementation
LL | fn one() {}
| ^^^
...
LL | fn two(&self) {}
| ^^^
...
LL | const CONSTANT: usize = 5;
| ^^^^^^^^
...
LL | type Type = usize;
| ^^^^
LL |
LL | fn three(&self) {
| ^^^^^
|
note: the lint level is defined here
--> $DIR/unused-assoc-fns.rs:3:9
|
LL | #![deny(unused)]
| ^^^^^^
= note: `#[deny(dead_code)]` implied by `#[deny(unused)]`
error: aborting due to previous error

View File

@ -0,0 +1,17 @@
// Ensures that the alignment check we insert for raw pointer dereferences
// does not prevent crates without a panic_impl from compiling.
// See rust-lang/rust#109996
// build-pass
// compile-flags: -Cdebug-assertions=yes
#![crate_type = "lib"]
#![feature(lang_items)]
#![feature(no_core)]
#![no_core]
#[lang = "sized"]
trait Foo {}
pub unsafe fn foo(x: *const i32) -> &'static i32 { unsafe { &*x } }

View File

@ -50,7 +50,8 @@ LL | Pin::new(x)
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required by a bound in `Pin::<P>::new`
--> $SRC_DIR/core/src/pin.rs:LL:COL
@ -62,7 +63,8 @@ LL | Pin::new(Box::new(x))
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required by a bound in `Pin::<P>::new`
--> $SRC_DIR/core/src/pin.rs:LL:COL

View File

@ -39,7 +39,8 @@ LL | f_unpin(static || { yield; });
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required by a bound in `f_unpin`
--> $DIR/issue-84973-blacklist.rs:8:15
|

View File

@ -0,0 +1,23 @@
use std::pin::Pin;
use std::marker::PhantomPinned;
#[derive(Debug)]
struct Test {
_marker: PhantomPinned,
}
impl Test {
fn new() -> Self {
Test {
_marker: PhantomPinned, // This makes our type `!Unpin`
}
}
}
fn dummy(_: &mut Test) {}
pub fn main() {
let mut test1 = Test::new();
let mut test1 = unsafe { Pin::new_unchecked(&mut test1) };
dummy(test1.get_mut()); //~ ERROR E0277
}

View File

@ -0,0 +1,19 @@
error[E0277]: `PhantomPinned` cannot be unpinned
--> $DIR/suggest-pin-macro.rs:22:17
|
LL | dummy(test1.get_mut());
| ^^^^^^^ within `Test`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `Test`
--> $DIR/suggest-pin-macro.rs:5:8
|
LL | struct Test {
| ^^^^
note: required by a bound in `Pin::<&'a mut T>::get_mut`
--> $SRC_DIR/core/src/pin.rs:LL:COL
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View File

@ -6,7 +6,8 @@ LL | copy(r, w);
| |
| required by a bound introduced by this call
|
= note: consider using `Box::pin`
= note: consider using the `pin!` macro
consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required by a bound in `copy`
--> $DIR/issue-90164.rs:1:12
|

View File

@ -0,0 +1,12 @@
struct NeedsDropTypes<'tcx, F>(std::marker::PhantomData<&'tcx F>);
impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
//~^ ERROR type annotations needed
where
F: Fn(&Missing) -> Result<I, ()>,
//~^ ERROR cannot find type `Missing` in this scope
I: Iterator<Item = Missing>,
//~^ ERROR cannot find type `Missing` in this scope
{}
fn main() {}

View File

@ -0,0 +1,32 @@
error[E0412]: cannot find type `Missing` in this scope
--> $DIR/issue-110157.rs:6:12
|
LL | F: Fn(&Missing) -> Result<I, ()>,
| ^^^^^^^ not found in this scope
error[E0412]: cannot find type `Missing` in this scope
--> $DIR/issue-110157.rs:8:24
|
LL | I: Iterator<Item = Missing>,
| ^^^^^^^ not found in this scope
error[E0283]: type annotations needed
--> $DIR/issue-110157.rs:3:31
|
LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `I`
|
= note: cannot satisfy `_: Iterator`
note: required for `NeedsDropTypes<'tcx, F>` to implement `Iterator`
--> $DIR/issue-110157.rs:3:18
|
LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F>
| ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
...
LL | I: Iterator<Item = Missing>,
| ------------------------ unsatisfied trait bound introduced here
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0283, E0412.
For more information about an error, try `rustc --explain E0283`.