Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #81165

Merged
merged 100 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
c06793b
Add Roadmap for 2021
flip1995 Dec 15, 2020
469281c
Check if never type feature is enabled by TyCtxt before suggesting em…
nahuakang Dec 28, 2020
83a458a
Enable never type in empty enum ui test; run cargo dev bless
nahuakang Dec 28, 2020
275988c
Add additional lint doc to known problems section
nahuakang Dec 28, 2020
af480a6
Ensure `Copy` exception in trait definition for `wrong_self_conventio…
ThibsG Dec 30, 2020
0afe2db
Update CHANGELOG for Rust 1.50
phansch Dec 30, 2020
b81111b
Address review comments
phansch Dec 30, 2020
6b37932
Fix blessing of test output in subdirectories
phansch Dec 31, 2020
6909055
s/test_dir/test_suite_dir
phansch Dec 31, 2020
5d48b91
field_reassign_with_default: don't expand macros in suggestion
matthiaskrgr Jan 1, 2021
ba4bf4f
Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup
flip1995 Jan 2, 2021
1853f8b
Add lint
Jarcho Jan 2, 2021
78f6009
Auto merge of #6520 - phansch:update-changelog, r=flip1995
bors Jan 2, 2021
053afe4
Use bootstrap rustc for versioncheck in Clippy
flip1995 Jan 2, 2021
9427e03
Fix clone_on_copy test
Jarcho Jan 2, 2021
d37ee6f
Fix lint errors
Jarcho Jan 2, 2021
592f7eb
Auto merge of #6531 - matthiaskrgr:6522, r=ebroto
bors Jan 2, 2021
a02806e
Auto merge of #6518 - ThibsG:CopyException, r=ebroto
bors Jan 2, 2021
7b5f549
Fix docs: use type inference
Jarcho Jan 3, 2021
8951916
Auto merge of #6525 - phansch:fix-bless-in-subdirs, r=flip1995
bors Jan 4, 2021
d141cdc
Add prioritization chapter and remove unresolved questions
flip1995 Jan 4, 2021
6dcec6a
collapsible_if: split collapsible_else_if into its own lint so we can…
matthiaskrgr Jan 4, 2021
dd1929e
Auto merge of #6544 - matthiaskrgr:else_if, r=flip1995
bors Jan 4, 2021
ba87acb
Implemented needless question mark lint
bengsparks Dec 26, 2020
ae9ae97
Auto merge of #6507 - bengsparks:lint/issue6410, r=flip1995
bors Jan 4, 2021
7acfa44
Add ui-internal to cargo dev bless
camsteffen Dec 31, 2020
cbbb188
Bless only updated since clippy build
camsteffen Dec 31, 2020
445eb99
Auto merge of #6548 - camsteffen:bless-internal, r=flip1995
bors Jan 4, 2021
bc97f5d
Address flip1995's review comments
nahuakang Jan 4, 2021
a8d47b4
Run cargo dev fmt
nahuakang Jan 4, 2021
976850b
Auto merge of #6538 - Jarcho:vec_init_then_push, r=llogiq
bors Jan 4, 2021
4b478a5
Add a new lint `ptr_as_ptr`,
rail-rain Jan 3, 2021
dfa5d7e
Fix the MSRV and add the tests for MSRV
rail-rain Jan 4, 2021
dd52066
Auto merge of #6547 - camsteffen:curse-outdated, r=phansch
bors Jan 5, 2021
311186b
Auto merge of #6513 - nahuakang:fix/empty_enum_lint_never_type, r=fli…
bors Jan 5, 2021
a6b72d3
Auto merge of #6542 - rail-rain:ptr_as_ptr, r=flip1995
bors Jan 5, 2021
ea885d9
Tiny Symbol cleanup
phansch Jan 5, 2021
42b9e92
Auto merge of #6551 - phansch:tiny-symbol-cleanup, r=flip1995
bors Jan 5, 2021
a8825e9
Use existing 'is_automatically_derived' helper
phansch Jan 5, 2021
92f2bbb
Fix macro issues with field_reassign_with_default
phansch Jan 5, 2021
efccfe8
Auto merge of #6553 - phansch:field-reassign-with-default-macros, r=f…
bors Jan 6, 2021
8a45ffa
Fix typo: `which which can be` -> `which can be`
sozysozbot Jan 6, 2021
8e5c5a6
Auto merge of #6554 - sozysozbot:master, r=flip1995
bors Jan 6, 2021
f50ded0
Catch `pointer::cast` too in `cast_ptr_alignment`
rail-rain Jan 7, 2021
547ce0d
Change env var used for testing Clippy
flip1995 Jan 7, 2021
2b3c0ad
Fix typo: `irrevelent` -> `irrelevant`
stanislav-tkach Jan 7, 2021
e15bef9
Auto merge of #6558 - stanislav-tkach:patch-2, r=flip1995
bors Jan 7, 2021
7d42172
Reintroduce hir::ExprKind::If
c410-f3r Jan 1, 2021
aa9adbf
Small fixes of doc in `needless_question_mark`
giraffate Jan 7, 2021
0e14a75
Reduce the span in `from_over_into` to impl header
giraffate Jan 7, 2021
ee9b47d
Move `is_hir_ty_cfg_dependant` to `util`,
rail-rain Jan 8, 2021
2950c8e
Auto merge of #6566 - giraffate:reduce_the_span_in_from_over_into, r=…
bors Jan 8, 2021
24c700b
Use DefId in interning defined symbol lint
camsteffen Dec 30, 2020
121c65f
Add keywords to interning defined symbol lint
camsteffen Dec 29, 2020
76ccfb4
Fix unnecessary keyword intern dogfood
camsteffen Dec 29, 2020
cc26919
Add unnecessary symbol string lint
camsteffen Dec 30, 2020
7871eba
Fix symbol string comparison dogfood
camsteffen Dec 29, 2020
68bcd20
Auto merge of #6569 - camsteffen:symbol-comparison, r=Manishearth
bors Jan 8, 2021
8a6fea4
Fix FP for `boxed_local` lint in default trait fn impl
ThibsG Jan 9, 2021
ee0598e
Auto merge of #6571 - ThibsG:BoxedLocalTrait, r=phansch
bors Jan 9, 2021
583715f
Auto merge of #6565 - giraffate:small_fixes_of_doc_in_needless_questi…
bors Jan 9, 2021
9e45a23
ast: Remove some indirection layers from values in key-value attributes
petrochenkov Dec 19, 2020
2c6dc88
Rework diagnostics for wrong number of generic args
Patryk27 Jan 2, 2021
1eed27f
Auto merge of #6575 - flip1995:stop_linting_deps, r=Manishearth
bors Jan 11, 2021
53f8731
Simplify `cast_ptr_alignment` `pointer::casr` case
rail-rain Jan 11, 2021
7f4599a
Auto merge of #6557 - rail-rain:extending_cast_ptr_alignment, r=phansch
bors Jan 11, 2021
13ca5c8
Auto merge of #6462 - flip1995:roadmap, r=flip1995,llogiq,killercup,M…
bors Jan 12, 2021
ea02849
Make a reference a link in doc
giraffate Jan 13, 2021
dfb41f4
Separate out a `hir::Impl` struct
jyn514 Nov 22, 2020
00586df
Auto merge of #6584 - giraffate:make_references_to_issues_links, r=ll…
bors Jan 13, 2021
dcd8c8e
Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
bors Jan 13, 2021
7b3af41
Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasper
bors Jan 14, 2021
9bd037d
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jan 15, 2021
0c5ba9a
Bump nightly version to 2021-01-15
flip1995 Jan 15, 2021
f18cf82
Don't trigger needless_return lint in macros
flip1995 Jan 15, 2021
953f024
Auto merge of #6586 - flip1995:rustup, r=flip1995
bors Jan 15, 2021
3e236b3
Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyup
flip1995 Jan 15, 2021
84b056d
prevent potential bug in `encode_with_shorthand`.
lcnr Jan 16, 2021
0a74e17
Initialize a few variables directly
LingMan Jan 17, 2021
428f948
Copy body span instead of querying it
bugadani Jan 17, 2021
9111e9d
rustc_parse_format: Fix character indices in find_skips
osa1 Jan 16, 2021
c7bad7b
Avoid logging the whole MIR body in SimplifyCfg
tmiasko Jan 17, 2021
7276b6c
Update cmp.rs
sirh3e Jan 17, 2021
394d701
Add track_caller to .steal()
jyn514 Jan 17, 2021
514543a
validation test: turn some const_err back into validation failures
RalfJung Jan 17, 2021
34debb6
Edit rustc_middle::ty::cast docs
pierwill Jan 17, 2021
e23acc3
Replace let Some(..) = with .is_some()
wcampbell0x2a Jan 18, 2021
d5570c2
Remove unused linkcheck exceptions
jyn514 Jan 18, 2021
090ab8c
Rollup merge of #81038 - flip1995:clippyup, r=Manishearth
KodrAus Jan 18, 2021
c7ca540
Rollup merge of #81071 - osa1:fix_81006, r=estebank
KodrAus Jan 18, 2021
d3ff9ac
Rollup merge of #81100 - lcnr:encode_with_shorthand, r=oli-obk
KodrAus Jan 18, 2021
b4defec
Rollup merge of #81105 - LingMan:init_directly, r=nagisa
KodrAus Jan 18, 2021
064e47b
Rollup merge of #81116 - bugadani:body-span, r=wesleywiser
KodrAus Jan 18, 2021
e1d70bc
Rollup merge of #81121 - tmiasko:simplify-cfg-no-dbg, r=jonas-schievink
KodrAus Jan 18, 2021
0654e20
Rollup merge of #81123 - sirh3e:sirh3e-patch-1, r=sfackler
KodrAus Jan 18, 2021
f82100e
Rollup merge of #81125 - jyn514:track-caller, r=lcnr
KodrAus Jan 18, 2021
8f1716c
Rollup merge of #81128 - RalfJung:validation-testing, r=oli-obk
KodrAus Jan 18, 2021
d3cc598
Rollup merge of #81131 - pierwill:edit-rustc_middle-cast, r=varkor
KodrAus Jan 18, 2021
0068358
Rollup merge of #81142 - wcampbell0x2a:replace-Some-with-is-some, r=j…
KodrAus Jan 18, 2021
33d184b
Rollup merge of #81153 - jyn514:linkcheck, r=Manishearth
KodrAus Jan 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ impl MetaItemKind {
fn list_from_tokens(tokens: TokenStream) -> Option<MetaItemKind> {
let mut tokens = tokens.into_trees().peekable();
let mut result = Vec::new();
while let Some(..) = tokens.peek() {
while tokens.peek().is_some() {
let item = NestedMetaItem::from_tokens(&mut tokens)?;
result.push(item);
match tokens.next() {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_data_structures/src/steal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ impl<T> Steal<T> {
Steal { value: RwLock::new(Some(value)) }
}

#[track_caller]
pub fn borrow(&self) -> MappedReadGuard<'_, T> {
ReadGuard::map(self.value.borrow(), |opt| match *opt {
None => panic!("attempted to read from stolen value"),
Some(ref v) => v,
})
}

#[track_caller]
pub fn steal(&self) -> T {
let value_ref = &mut *self.value.try_write().expect("stealing value which is locked");
let value = value_ref.take();
value.expect("attempt to read from stolen value")
value.expect("attempt to steal from stolen value")
}
}

Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_middle/src/ty/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ pub enum CastTy<'tcx> {
/// Various types that are represented as ints and handled mostly
/// in the same way, merged for easier matching.
Int(IntTy),
/// Floating-Point types
/// Floating-point types.
Float,
/// Function Pointers
/// Function pointers.
FnPtr,
/// Raw pointers
/// Raw pointers.
Ptr(ty::TypeAndMut<'tcx>),
}

/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)
/// Cast Kind. See [RFC 401](https://rust-lang.github.io/rfcs/0401-coercions.html)
/// (or librustc_typeck/check/cast.rs).
#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)]
pub enum CastKind {
CoercionCast,
Expand All @@ -48,7 +49,7 @@ pub enum CastKind {

impl<'tcx> CastTy<'tcx> {
/// Returns `Some` for integral/pointer casts.
/// casts like unsizing casts will return `None`
/// Casts like unsizing casts will return `None`.
pub fn from_ty(t: Ty<'tcx>) -> Option<CastTy<'tcx>> {
match *t.kind() {
ty::Bool => Some(CastTy::Int(IntTy::Bool)),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use rustc_span::Span;
use std::convert::{TryFrom, TryInto};
use std::hash::Hash;
use std::intrinsics;
use std::marker::DiscriminantKind;
Expand Down Expand Up @@ -81,7 +80,8 @@ where
E: TyEncoder<'tcx>,
M: for<'b> Fn(&'b mut E) -> &'b mut FxHashMap<T, usize>,
T: EncodableWithShorthand<'tcx, E>,
<T::Variant as DiscriminantKind>::Discriminant: Ord + TryFrom<usize>,
// The discriminant and shorthand must have the same size.
T::Variant: DiscriminantKind<Discriminant = isize>,
{
let existing_shorthand = cache(encoder).get(value).copied();
if let Some(shorthand) = existing_shorthand {
Expand All @@ -97,7 +97,7 @@ where
// The shorthand encoding uses the same usize as the
// discriminant, with an offset so they can't conflict.
let discriminant = intrinsics::discriminant_value(variant);
assert!(discriminant < SHORTHAND_OFFSET.try_into().ok().unwrap());
assert!(SHORTHAND_OFFSET > discriminant as usize);

let shorthand = start + SHORTHAND_OFFSET;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
let mut body =
new_body(source, blocks, local_decls_for_sig(&sig, span), sig.inputs().len(), span);

if let Some(..) = ty {
if ty.is_some() {
// The first argument (index 0), but add 1 for the return value.
let dropee_ptr = Place::from(Local::new(1 + 0));
if tcx.sess.opts.debugging_opts.mir_emit_retag {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
Default::default(),
body.arg_count,
Default::default(),
tcx.def_span(def_id),
body.span,
body.generator_kind,
);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyCfg {
}

fn run_pass(&self, _tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body);
debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body.source);
simplify_cfg(body);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse_format/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ fn find_skips_from_snippet(

fn find_skips(snippet: &str, is_raw: bool) -> Vec<usize> {
let mut eat_ws = false;
let mut s = snippet.chars().enumerate().peekable();
let mut s = snippet.char_indices().peekable();
let mut skips = vec![];
while let Some((pos, c)) = s.next() {
match (c, s.peek()) {
Expand Down
21 changes: 9 additions & 12 deletions compiler/rustc_resolve/src/late/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1398,12 +1398,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
fn lifetime_deletion_span(&self, name: Ident, generics: &hir::Generics<'_>) -> Option<Span> {
generics.params.iter().enumerate().find_map(|(i, param)| {
if param.name.ident() == name {
let mut in_band = false;
if let hir::GenericParamKind::Lifetime { kind } = param.kind {
if let hir::LifetimeParamKind::InBand = kind {
in_band = true;
}
}
let in_band = matches!(
param.kind,
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::InBand }
);
if in_band {
Some(param.span)
} else if generics.params.len() == 1 {
Expand Down Expand Up @@ -1433,12 +1431,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
lifetime: &hir::Lifetime,
) {
let name = lifetime.name.ident();
let mut remove_decl = None;
if let Some(parent_def_id) = self.tcx.parent(def_id) {
if let Some(generics) = self.tcx.hir().get_generics(parent_def_id) {
remove_decl = self.lifetime_deletion_span(name, generics);
}
}
let remove_decl = self
.tcx
.parent(def_id)
.and_then(|parent_def_id| self.tcx.hir().get_generics(parent_def_id))
.and_then(|generics| self.lifetime_deletion_span(name, generics));

let mut remove_use = None;
let mut elide_use = None;
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl Ordering {
/// assert_eq!(result, Ordering::Equal);
///
/// let x: (i64, i64, i64) = (1, 2, 7);
/// let y: (i64, i64, i64) = (1, 5, 3);
/// let y: (i64, i64, i64) = (1, 5, 3);
/// let result = x.0.cmp(&y.0).then_with(|| x.1.cmp(&y.1)).then_with(|| x.2.cmp(&y.2));
///
/// assert_eq!(result, Ordering::Less);
Expand Down
26 changes: 14 additions & 12 deletions src/test/ui/consts/const-eval/ub-wide-ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ use std::mem;
// normalize-stderr-test "alloc\d+" -> "allocN"
// normalize-stderr-test "size \d+" -> "size N"

/// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error
/// message. Use this whenever the message is "any use of this value will cause an error" instead of
/// "it is undefined behavior to use this value".
#[repr(transparent)]
struct W<T>(T);

#[repr(C)]
union MaybeUninit<T: Copy> {
uninit: (),
Expand Down Expand Up @@ -95,26 +101,22 @@ const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {

// # trait object
// bad trait object
#[warn(const_err)]
const TRAIT_OBJ_SHORT_VTABLE_1: &dyn Trait = unsafe { mem::transmute((&92u8, &3u8)) };
//~^ WARN any use of this value will cause an error [const_err]
const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
//~^ ERROR it is undefined behavior to use this value
// bad trait object
#[warn(const_err)]
const TRAIT_OBJ_SHORT_VTABLE_2: &dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
//~^ WARN any use of this value will cause an error [const_err]
const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
//~^ ERROR it is undefined behavior to use this value
// bad trait object
#[warn(const_err)]
const TRAIT_OBJ_INT_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, 4usize)) };
//~^ WARN any use of this value will cause an error [const_err]
const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
//~^ ERROR it is undefined behavior to use this value
const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
//~^ ERROR it is undefined behavior to use this value
const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
//~^ ERROR it is undefined behavior to use this value
const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
//~^ ERROR it is undefined behavior to use this value
#[warn(const_err)]
const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: &dyn Trait = unsafe { mem::transmute((&92u8, &[&42u8; 8])) };
//~^ WARN any use of this value will cause an error [const_err]
const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
//~^ ERROR it is undefined behavior to use this value

// bad data *inside* the trait object
const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
Expand Down
Loading