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 7 pull requests #75276

Merged
merged 35 commits into from
Aug 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bbcacdd
Don't call a function in function-arguments-naked.rs
Aaron1011 Aug 6, 2020
0aee186
make MaybeUninit::as_(mut_)ptr const
RalfJung Aug 7, 2020
ec5d78d
fix feature gate and tracking issue
RalfJung Aug 7, 2020
a530934
clean up const-hacks in int endianess conversion functions
RalfJung Aug 7, 2020
91dda2c
Only test function-arguments-naked.rs on x86_64
Aaron1011 Aug 7, 2020
c34c77c
Apply `extern "C"` calling convention
Aaron1011 Aug 7, 2020
7d4565b
Add missing backtick
giraffate Aug 5, 2020
7e9a848
Small cleanup
estebank Aug 7, 2020
3ef8c72
fix clippy::expect_fun_call: use unwrap_or_else to prevent panic mess…
matthiaskrgr Aug 1, 2020
8bc1f91
fix clippy::filter_next: use .find(..) instead of .filter(..).next()
matthiaskrgr Aug 1, 2020
fca81fa
fix clippy::iter_next_slice: use .get(0) instead of .iter().next()
matthiaskrgr Aug 1, 2020
fb975cd
fix clippy::map_identity: remove redundant .map(|x| x) call
matthiaskrgr Aug 1, 2020
27bb689
fix clippy::redundant_clone: remove redundant clones
matthiaskrgr Aug 1, 2020
09e29e7
fix clippy::redundant_pattern_matching: use .is_some() instead of if …
matthiaskrgr Aug 1, 2020
f3ec5be
fix clippy::single_char_pattern: use char instead of string single-ch…
matthiaskrgr Aug 1, 2020
a1c2212
fix clippy::unit_arg: make it explicit that Ok(()) is being returned
matthiaskrgr Aug 1, 2020
f6b1857
fix clippy::unnecessary_mut_passed: function arg is not required to b…
matthiaskrgr Aug 1, 2020
eccc2fe
fix clippy::unneeded_wildcard_pattern: remove redundant wildcard pattern
matthiaskrgr Aug 1, 2020
057730c
fix clippy::len_zero: use is_empty() instead of comparing .len() to zero
matthiaskrgr Aug 1, 2020
63c0d9c
Display elided lifetime for non-reference type in doc
nbdd0121 Aug 6, 2020
505d157
Display elided lifetime for external paths
nbdd0121 Aug 7, 2020
f95cfe5
fix clippy::redundant_closure: remove redundant closures and call fun…
matthiaskrgr Aug 7, 2020
ea9ccfa
fix clippy::while_let_loop: use while let{} instead of loop { if ... …
matthiaskrgr Aug 7, 2020
4ba1a19
fix clippy::into_iter_on_ref: use .iter() instead of into_iter() on r…
matthiaskrgr Aug 7, 2020
15dcda3
fix clippy::map_clone: use .cloned() instead of .map(|x| x.clone())
matthiaskrgr Aug 7, 2020
ff692ab
fix clippy::clone_on_copy: don't clone types that are copy
matthiaskrgr Aug 7, 2020
a605e51
fix clippy::needless_return: remove unneeded return statements
matthiaskrgr Aug 7, 2020
541fbbb
Cross-crate doc inlining test case for elided lifetime
nbdd0121 Aug 8, 2020
f5d2ffd
Rollup merge of #75224 - Aaron1011:fix/function-arguments-naked, r=Am…
JohnTitor Aug 8, 2020
255434d
Rollup merge of #75237 - nbdd0121:rustdoc, r=jyn514
JohnTitor Aug 8, 2020
b032a15
Rollup merge of #75250 - RalfJung:uninit-const-ptr, r=oli-obk
JohnTitor Aug 8, 2020
02bf036
Rollup merge of #75253 - RalfJung:cleanup-const-hack, r=oli-obk
JohnTitor Aug 8, 2020
2c1fe50
Rollup merge of #75259 - giraffate:add_missing_backtick, r=lcnr
JohnTitor Aug 8, 2020
81546de
Rollup merge of #75267 - estebank:cleanup, r=Dylan-DPC
JohnTitor Aug 8, 2020
21bfe52
Rollup merge of #75270 - matthiaskrgr:clippy_aug_1, r=Dylan-DPC
JohnTitor Aug 8, 2020
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
12 changes: 8 additions & 4 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,11 @@ impl<T> MaybeUninit<T> {
/// (Notice that the rules around references to uninitialized data are not finalized yet, but
/// until they are, it is advisable to avoid them.)
#[stable(feature = "maybe_uninit", since = "1.36.0")]
#[rustc_const_unstable(feature = "const_maybe_uninit_as_ptr", issue = "75251")]
#[inline(always)]
pub fn as_ptr(&self) -> *const T {
unsafe { &*self.value as *const T }
pub const fn as_ptr(&self) -> *const T {
// `MaybeUninit` and `ManuallyDrop` are both `repr(transparent)` so we can cast the pointer.
self as *const _ as *const T
}

/// Gets a mutable pointer to the contained value. Reading from this pointer or turning it
Expand Down Expand Up @@ -442,9 +444,11 @@ impl<T> MaybeUninit<T> {
/// (Notice that the rules around references to uninitialized data are not finalized yet, but
/// until they are, it is advisable to avoid them.)
#[stable(feature = "maybe_uninit", since = "1.36.0")]
#[rustc_const_unstable(feature = "const_maybe_uninit_as_ptr", issue = "75251")]
#[inline(always)]
pub fn as_mut_ptr(&mut self) -> *mut T {
unsafe { &mut *self.value as *mut T }
pub const fn as_mut_ptr(&mut self) -> *mut T {
// `MaybeUninit` and `ManuallyDrop` are both `repr(transparent)` so we can cast the pointer.
self as *mut _ as *mut T
}

/// Extracts the value from the `MaybeUninit<T>` container. This is a great way
Expand Down
36 changes: 8 additions & 28 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2346,17 +2346,12 @@ assert_eq!(
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always
// transmute them to arrays of bytes
#[allow_internal_unstable(const_fn_union)]
#[allow_internal_unstable(const_fn_transmute)]
#[inline]
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
#[repr(C)]
union Bytes {
val: $SelfT,
bytes: [u8; mem::size_of::<$SelfT>()],
}
// SAFETY: integers are plain old datatypes so we can always transmute them to
// arrays of bytes
unsafe { Bytes { val: self }.bytes }
unsafe { mem::transmute(self) }
}
}

Expand Down Expand Up @@ -2464,16 +2459,11 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always
// transmute to them
#[allow_internal_unstable(const_fn_union)]
#[allow_internal_unstable(const_fn_transmute)]
#[inline]
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
#[repr(C)]
union Bytes {
val: $SelfT,
bytes: [u8; mem::size_of::<$SelfT>()],
}
// SAFETY: integers are plain old datatypes so we can always transmute to them
unsafe { Bytes { bytes }.val }
unsafe { mem::transmute(bytes) }
}
}

Expand Down Expand Up @@ -4368,17 +4358,12 @@ assert_eq!(
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always
// transmute them to arrays of bytes
#[allow_internal_unstable(const_fn_union)]
#[allow_internal_unstable(const_fn_transmute)]
#[inline]
pub const fn to_ne_bytes(self) -> [u8; mem::size_of::<Self>()] {
#[repr(C)]
union Bytes {
val: $SelfT,
bytes: [u8; mem::size_of::<$SelfT>()],
}
// SAFETY: integers are plain old datatypes so we can always transmute them to
// arrays of bytes
unsafe { Bytes { val: self }.bytes }
unsafe { mem::transmute(self) }
}
}

Expand Down Expand Up @@ -4486,16 +4471,11 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always
// transmute to them
#[allow_internal_unstable(const_fn_union)]
#[allow_internal_unstable(const_fn_transmute)]
#[inline]
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
#[repr(C)]
union Bytes {
val: $SelfT,
bytes: [u8; mem::size_of::<$SelfT>()],
}
// SAFETY: integers are plain old datatypes so we can always transmute to them
unsafe { Bytes { bytes }.val }
unsafe { mem::transmute(bytes) }
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/test/src/helpers/concurrency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::env;

#[allow(deprecated)]
pub fn get_concurrency() -> usize {
return match env::var("RUST_TEST_THREADS") {
match env::var("RUST_TEST_THREADS") {
Ok(s) => {
let opt_n: Option<usize> = s.parse().ok();
match opt_n {
Expand All @@ -13,7 +13,7 @@ pub fn get_concurrency() -> usize {
}
}
Err(..) => num_cpus(),
};
}
}

cfg_if::cfg_if! {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ impl Default for Generics {
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct WhereClause {
/// `true` if we ate a `where` token: this can happen
/// if we parsed no predicates (e.g. `struct Foo where {}
/// if we parsed no predicates (e.g. `struct Foo where {}`).
/// This allows us to accurately pretty-print
/// in `nt_to_tokenstream`
pub has_where_token: bool,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,15 +960,15 @@ fn pointer_type_metadata(
fn param_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
debug!("param_type_metadata: {:?}", t);
let name = format!("{:?}", t);
return unsafe {
unsafe {
llvm::LLVMRustDIBuilderCreateBasicType(
DIB(cx),
name.as_ptr().cast(),
name.len(),
Size::ZERO.bits(),
DW_ATE_unsigned,
)
};
}
}

pub fn compile_unit_metadata(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
let _timer = sess.timer("copy_all_cgu_workproducts_to_incr_comp_cache_dir");

for module in compiled_modules.modules.iter().filter(|m| m.kind == ModuleKind::Regular) {
let path = module.object.as_ref().map(|path| path.clone());
let path = module.object.as_ref().cloned();

if let Some((id, product)) =
copy_cgu_workproduct_to_incr_comp_cache_dir(sess, &module.name, &path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {

debug!("try_report_named_anon_conflict: ret ty {:?}", ty);
if sub == &ty::ReStatic
&& v.0
.into_iter()
.filter(|t| t.span.desugaring_kind().is_none())
.next()
.is_some()
&& v.0.into_iter().find(|t| t.span.desugaring_kind().is_none()).is_some()
{
// If the failure is due to a `'static` requirement coming from a `dyn` or
// `impl` Trait that *isn't* caused by `async fn` desugaring, handle this case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
param.param_ty.to_string(),
Applicability::MaybeIncorrect,
);
} else if let Some(_) = opaque
} else if opaque
.bounds
.iter()
.filter_map(|arg| match arg {
Expand All @@ -269,6 +269,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
_ => None,
})
.next()
.is_some()
{
} else {
err.span_suggestion_verbose(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_infer/infer/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b),
ty::Covariant => self.relate(a, b),
// FIXME(#41044) -- not correct, need test
ty::Bivariant => Ok(a.clone()),
ty::Bivariant => Ok(a),
ty::Contravariant => self.fields.lub(self.a_is_expected).relate(a, b),
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
// very challenging, switch to invariance. This is obviously
// overly conservative but works ok in practice.
self.relate_with_variance(ty::Variance::Invariant, a, b)?;
Ok(a.clone())
Ok(a)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ where
self.a_scopes.pop().unwrap();
}

Ok(a.clone())
Ok(a)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_infer/infer/region_constraints/leak_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ impl<'me, 'tcx> LeakCheck<'me, 'tcx> {
) -> TypeError<'tcx> {
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
if self.overly_polymorphic {
return TypeError::RegionsOverlyPolymorphic(placeholder.name, other_region);
TypeError::RegionsOverlyPolymorphic(placeholder.name, other_region)
} else {
return TypeError::RegionsInsufficientlyPolymorphic(placeholder.name, other_region);
TypeError::RegionsInsufficientlyPolymorphic(placeholder.name, other_region)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
match variance {
ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b),
ty::Covariant => self.relate(a, b),
ty::Bivariant => Ok(a.clone()),
ty::Bivariant => Ok(a),
ty::Contravariant => self.with_expected_switched(|this| this.relate(b, a)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
}
// If `ty` is a `repr(transparent)` newtype, and the non-zero-sized type is a generic
// argument, which after substitution, is `()`, then this branch can be hit.
FfiResult::FfiUnsafe { ty, .. } if is_return_type && ty.is_unit() => return,
FfiResult::FfiUnsafe { ty, .. } if is_return_type && ty.is_unit() => {}
FfiResult::FfiUnsafe { ty, reason, help } => {
self.emit_ffi_unsafe_type_lint(ty, sp, &reason, help.as_deref());
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl<'a, 'tcx> SpecializedEncoder<ExpnId> for EncodeContext<'a, 'tcx> {
fn specialized_encode(&mut self, expn: &ExpnId) -> Result<(), Self::Error> {
rustc_span::hygiene::raw_encode_expn_id(
*expn,
&mut self.hygiene_ctxt,
&self.hygiene_ctxt,
ExpnDataEncodeMode::Metadata,
self,
)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/traits/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub struct DropckOutlivesResult<'tcx> {

impl<'tcx> DropckOutlivesResult<'tcx> {
pub fn report_overflows(&self, tcx: TyCtxt<'tcx>, span: Span, ty: Ty<'tcx>) {
if let Some(overflow_ty) = self.overflows.iter().next() {
if let Some(overflow_ty) = self.overflows.get(0) {
let mut err = struct_span_err!(
tcx.sess,
span,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
}
}
return normal_ret;
normal_ret
}

/// Finds the span of arguments of a closure (within `maybe_closure_span`)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/simplify_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ fn optimization_applies<'tcx>(
}

trace!("SUCCESS: optimization applies!");
return true;
true
}

impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub fn equal_up_to_regions(
T: Relate<'tcx>,
{
self.relate(a.skip_binder(), b.skip_binder())?;
Ok(a.clone())
Ok(a)
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ pub struct Parser<'a> {
/// error.
pub(super) unclosed_delims: Vec<UnmatchedBrace>,
last_unexpected_token_span: Option<Span>,
/// Span pointing at the `:` for the last type ascription the parser has seen, and whether it
/// looked like it could have been a mistyped path or literal `Option:Some(42)`).
pub last_type_ascription: Option<(Span, bool /* likely path typo */)>,
/// If present, this `Parser` is not parsing Rust code but rather a macro call.
subparser_name: Option<&'static str>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse_format/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ fn find_skips_from_snippet(
}

let r_start = str_style.map(|r| r + 1).unwrap_or(0);
let r_end = str_style.map(|r| r).unwrap_or(0);
let r_end = str_style.unwrap_or(0);
let s = &snippet[r_start + 1..snippet.len() - r_end - 1];
(find_skips(s, str_style.is_some()), true)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<'a> PathSource<'a> {
ValueNS => "method or associated constant",
MacroNS => bug!("associated macro"),
},
PathSource::Expr(parent) => match &parent.as_ref().map(|p| &p.kind) {
PathSource::Expr(parent) => match parent.as_ref().map(|p| &p.kind) {
// "function" here means "anything callable" rather than `DefKind::Fn`,
// this is not precise but usually more helpful than just "value".
Some(ExprKind::Call(call_expr, _)) => match &call_expr.kind {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ impl<'tcx> SaveContext<'tcx> {
Res::Def(HirDefKind::ConstParam, def_id) => {
Some(Ref { kind: RefKind::Variable, span, ref_id: id_from_def_id(def_id) })
}
Res::Def(HirDefKind::Ctor(_, ..), def_id) => {
Res::Def(HirDefKind::Ctor(..), def_id) => {
// This is a reference to a tuple struct or an enum variant where the def_id points
// to an invisible constructor function. That is not a very useful
// def, so adjust to point to the tuple struct or enum variant itself.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_session/filesearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'a> FileSearch<'a> {
p.push(RUST_LIB_DIR);
p.push(&self.triple);
p.push("bin");
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p.clone()] }
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_span/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ pub fn decode_expn_id<
drop(expns);
expn_id
});
return Ok(expn_id);
Ok(expn_id)
}

// Decodes `SyntaxContext`, using the provided `HygieneDecodeContext`
Expand Down Expand Up @@ -1103,7 +1103,7 @@ pub fn decode_syntax_context<
assert_eq!(dummy.dollar_crate_name, kw::Invalid);
});

return Ok(new_ctxt);
Ok(new_ctxt)
}

pub fn num_syntax_ctxts() -> usize {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trait_selection/autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
}

pub fn span(&self) -> Span {
self.span.clone()
self.span
}

pub fn reached_recursion_limit(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
if let Ok(src) = self.tcx.sess.source_map().span_to_snippet(span) {
// Don't care about `&mut` because `DerefMut` is used less
// often and user will not expect autoderef happens.
if src.starts_with("&") && !src.starts_with("&mut ") {
if src.starts_with('&') && !src.starts_with("&mut ") {
let derefs = "*".repeat(steps);
err.span_suggestion(
span,
Expand Down
Loading