diff options
| author | bors <bors@rust-lang.org> | 2021-01-18 14:36:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-18 14:36:30 +0000 |
| commit | 5e91c4ecc09312d8b63d250a432b0f3ef83f1df7 (patch) | |
| tree | 994a9e3c43f68368785e414945aa8949e2493c25 /compiler | |
| parent | 66eb9821666e0672a69a998d2331733c7a8996a5 (diff) | |
| parent | 33d184bfd093460d56a10c8a151b66147d2b4041 (diff) | |
| download | rust-5e91c4ecc09312d8b63d250a432b0f3ef83f1df7.tar.gz rust-5e91c4ecc09312d8b63d250a432b0f3ef83f1df7.zip | |
Auto merge of #81165 - KodrAus:rollup-s7llxis, r=KodrAus
Rollup of 12 pull requests Successful merges: - #81038 (Update Clippy) - #81071 (rustc_parse_format: Fix character indices in find_skips) - #81100 (prevent potential bug in `encode_with_shorthand`.) - #81105 (Initialize a few variables directly) - #81116 (ConstProp: Copy body span instead of querying it) - #81121 (Avoid logging the whole MIR body in SimplifyCfg) - #81123 (Update cmp.rs) - #81125 (Add track_caller to .steal()) - #81128 (validation test: turn some const_err back into validation failures) - #81131 (Edit rustc_middle::ty::cast docs) - #81142 (Replace let Some(..) = with .is_some()) - #81153 (Remove unused linkcheck exceptions) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast/src/attr/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/steal.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/cast.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/codec.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/shim.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/transform/const_prop.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/transform/simplify.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_parse_format/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/late/lifetimes.rs | 21 |
9 files changed, 26 insertions, 26 deletions
diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 6a54cb4766b..4dcbe4831be 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -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() { diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index e532a84cea3..7f9e4160fcd 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -30,6 +30,7 @@ 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"), @@ -37,10 +38,11 @@ impl<T> Steal<T> { }) } + #[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") } } diff --git a/compiler/rustc_middle/src/ty/cast.rs b/compiler/rustc_middle/src/ty/cast.rs index b47d9c50e1d..d737d1ebf56 100644 --- a/compiler/rustc_middle/src/ty/cast.rs +++ b/compiler/rustc_middle/src/ty/cast.rs @@ -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, @@ -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)), diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index a7b0ff45b97..0dad5df4855 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -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; @@ -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 { @@ -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; diff --git a/compiler/rustc_mir/src/shim.rs b/compiler/rustc_mir/src/shim.rs index aa5835686a2..b740dfaca32 100644 --- a/compiler/rustc_mir/src/shim.rs +++ b/compiler/rustc_mir/src/shim.rs @@ -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 { diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs index a311e262dd4..354d213689e 100644 --- a/compiler/rustc_mir/src/transform/const_prop.rs +++ b/compiler/rustc_mir/src/transform/const_prop.rs @@ -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, ); diff --git a/compiler/rustc_mir/src/transform/simplify.rs b/compiler/rustc_mir/src/transform/simplify.rs index b7c9a3a8688..289231e52cb 100644 --- a/compiler/rustc_mir/src/transform/simplify.rs +++ b/compiler/rustc_mir/src/transform/simplify.rs @@ -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); } } diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index f7b16bd991b..f150f7a41ae 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -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()) { diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index 1be06a44687..64cc113dffe 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -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 { @@ -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; |
