Skip to content

Rollup of 9 pull requests #58726

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c654968
Deny the `overflowing_literals` lint for all editions
ollie27 Jan 17, 2019
46f1cc6
reduce miri code repetition like (n << amt) >> amt
kenta7777 Feb 23, 2019
e7296fd
Fix error index E0370 doctests on 32 bit platforms
ollie27 Feb 24, 2019
423ae56
reduce a code repetition like (n << amt) >> amt
kenta7777 Feb 24, 2019
4ca865e
heading # Unsafety => # Safety in stdlib docs.
Centril Feb 25, 2019
9661a81
librustc_codegen_llvm: deny(elided_lifetimes_in_paths)
Centril Feb 25, 2019
1d34f2c
librustc_codegen_ssa: deny(elided_lifetimes_in_paths)
Centril Feb 25, 2019
e8ce56f
librustc_typeck: deny(elided_lifetimes_in_paths)
Centril Feb 25, 2019
235d3ed
librustc: deny(elided_lifetimes_in_paths)
Centril Feb 25, 2019
7029094
Test that binop subtyping in rustc_typeck fixes #27949
jamwt Feb 25, 2019
154b218
Rollup merge of #55632 - ollie27:deny_overflowing_literals, r=Centril
Centril Feb 25, 2019
504c8f4
Rollup merge of #58687 - kenta7777:reduce-miri-code-repetition, r=oli…
Centril Feb 25, 2019
f58ff22
Rollup merge of #58690 - kenta7777:reduce-code-repetition-miri-relate…
Centril Feb 25, 2019
3f96844
Rollup merge of #58718 - Centril:doc-convention-safety, r=RalfJung
Centril Feb 25, 2019
ffdeb72
Rollup merge of #58719 - Centril:deny-elided_lifetimes_in_paths, r=ol…
Centril Feb 25, 2019
88d35d2
Rollup merge of #58720 - Centril:deny-elided_lifetimes_in_paths-libru…
Centril Feb 25, 2019
6403e0e
Rollup merge of #58722 - Centril:deny-elided_lifetimes_in_paths-libru…
Centril Feb 25, 2019
8af9334
Rollup merge of #58723 - Centril:deny-elided_lifetimes_in_paths-libru…
Centril Feb 25, 2019
f8e3e66
Rollup merge of #58725 - jamwt:fix-27949, r=Centril
Centril Feb 25, 2019
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
20 changes: 20 additions & 0 deletions src/doc/rustc/src/lints/listing/deny-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,26 @@ error: const items should never be #[no_mangle]
|
```

## overflowing-literals

This lint detects literal out of range for its type. Some
example code that triggers this lint:

```rust,compile_fail
let x: u8 = 1000;
```

This will produce:

```text
error: literal out of range for u8
--> src/main.rs:2:17
|
2 | let x: u8 = 1000;
| ^^^^
|
```

## parenthesized-params-in-types-and-modules

This lint detects incorrect parentheses. Some example code that triggers this
Expand Down
20 changes: 0 additions & 20 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,6 @@ warning: functions generic over types must be mangled
|
```

## overflowing-literals

This lint detects literal out of range for its type. Some
example code that triggers this lint:

```rust
let x: u8 = 1000;
```

This will produce:

```text
warning: literal out of range for u8
--> src/main.rs:2:17
|
2 | let x: u8 = 1000;
| ^^^^
|
```

## path-statements

This lint detects path statements with no effect. Some example code that
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl fmt::Display for CannotReallocInPlace {
/// }
/// ```
///
/// # Unsafety
/// # Safety
///
/// The `GlobalAlloc` trait is an `unsafe` trait for a number of reasons, and
/// implementors must ensure that they adhere to these contracts:
Expand Down Expand Up @@ -643,7 +643,7 @@ pub unsafe trait GlobalAlloc {
/// currently allocated via an allocator `a`, then it is legal to
/// use that layout to deallocate it, i.e., `a.dealloc(ptr, k);`.
///
/// # Unsafety
/// # Safety
///
/// The `Alloc` trait is an `unsafe` trait for a number of reasons, and
/// implementors must ensure that they adhere to these contracts:
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ impl<T> MaybeUninit<T> {
/// to ensure that the data will get dropped, because the resulting `T` is
/// subject to the usual drop handling.
///
/// # Unsafety
/// # Safety
///
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
/// state. Calling this when the content is not yet fully initialized causes undefined
Expand All @@ -1187,7 +1187,7 @@ impl<T> MaybeUninit<T> {

/// Gets a reference to the contained value.
///
/// # Unsafety
/// # Safety
///
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
/// state. Calling this when the content is not yet fully initialized causes undefined
Expand All @@ -1200,7 +1200,7 @@ impl<T> MaybeUninit<T> {

/// Gets a mutable reference to the contained value.
///
/// # Unsafety
/// # Safety
///
/// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
/// state. Calling this when the content is not yet fully initialized causes undefined
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ impl<T> [T] {
/// This method has no purpose when either input element `T` or output element `U` are
/// zero-sized and will return the original slice without splitting anything.
///
/// # Unsafety
/// # Safety
///
/// This method is essentially a `transmute` with respect to the elements in the returned
/// middle slice, so all the usual caveats pertaining to `transmute::<T, U>` also apply here.
Expand Down Expand Up @@ -2211,7 +2211,7 @@ impl<T> [T] {
/// This method has no purpose when either input element `T` or output element `U` are
/// zero-sized and will return the original slice without splitting anything.
///
/// # Unsafety
/// # Safety
///
/// This method is essentially a `transmute` with respect to the elements in the returned
/// middle slice, so all the usual caveats pertaining to `transmute::<T, U>` also apply here.
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@

#![recursion_limit="512"]

#![warn(elided_lifetimes_in_paths)]

#[macro_use] extern crate bitflags;
extern crate getopts;
#[macro_use] extern crate lazy_static;
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::hir;
use crate::hir::def_id::DefId;
use crate::infer::canonical::Canonical;
use crate::mir::interpret::ConstValue;
use crate::mir::interpret::{ConstValue, truncate};
use crate::middle::region;
use polonius_engine::Atom;
use rustc_data_structures::indexed_vec::Idx;
Expand Down Expand Up @@ -2118,8 +2118,7 @@ impl<'tcx> Const<'tcx> {
let size = tcx.layout_of(ty).unwrap_or_else(|e| {
panic!("could not compute layout for {:?}: {:?}", ty, e)
}).size;
let shift = 128 - size.bits();
let truncated = (bits << shift) >> shift;
let truncated = truncate(bits, size);
assert_eq!(truncated, bits, "from_bits called with untruncated value");
Self::from_scalar(Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy};
use crate::ModuleLlvm;
use crate::llvm::{self, False, True};

pub(crate) unsafe fn codegen(tcx: TyCtxt, mods: &mut ModuleLlvm, kind: AllocatorKind) {
pub(crate) unsafe fn codegen(tcx: TyCtxt<'_, '_, '_>, mods: &mut ModuleLlvm, kind: AllocatorKind) {
let llcx = &*mods.llcx;
let llmod = mods.llmod();
let usize = match &tcx.sess.target.target.target_pointer_width[..] {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ pub fn from_fn_attrs(
}
}

pub fn provide(providers: &mut Providers) {
pub fn provide(providers: &mut Providers<'_>) {
providers.target_features_whitelist = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE);
if tcx.sess.opts.actually_rustdoc {
Expand All @@ -328,7 +328,7 @@ pub fn provide(providers: &mut Providers) {
provide_extern(providers);
}

pub fn provide_extern(providers: &mut Providers) {
pub fn provide_extern(providers: &mut Providers<'_>) {
providers.wasm_import_module_map = |tcx, cnum| {
// Build up a map from DefId to a `NativeLibrary` structure, where
// `NativeLibrary` internally contains information about
Expand Down Expand Up @@ -362,7 +362,7 @@ pub fn provide_extern(providers: &mut Providers) {
};
}

fn wasm_import_module(tcx: TyCtxt, id: DefId) -> Option<CString> {
fn wasm_import_module(tcx: TyCtxt<'_, '_, '_>, id: DefId) -> Option<CString> {
tcx.wasm_import_module_map(id.krate)
.get(&id)
.map(|s| CString::new(&s[..]).unwrap())
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum Addition {
},
}

fn is_relevant_child(c: &Child) -> bool {
fn is_relevant_child(c: &Child<'_>) -> bool {
match c.name() {
Some(name) => !name.contains("SYMDEF"),
None => false,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &
}

impl<'a> fmt::Display for Escape<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_like_msvc {
// This is "documented" at
// https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_codegen_llvm/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct RPathConfig<'a> {
pub get_install_prefix_lib_path: &'a mut dyn FnMut() -> PathBuf,
}

pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec<String> {
pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {
// No rpath on windows
if !config.has_rpath {
return Vec::new();
Expand Down Expand Up @@ -52,7 +52,7 @@ fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
ret
}

fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec<String> {
fn get_rpaths(config: &mut RPathConfig<'_>, libs: &[PathBuf]) -> Vec<String> {
debug!("output: {:?}", config.out_filename.display());
debug!("libs:");
for libpath in libs {
Expand Down Expand Up @@ -86,12 +86,12 @@ fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec<String> {
rpaths
}

fn get_rpaths_relative_to_output(config: &mut RPathConfig,
fn get_rpaths_relative_to_output(config: &mut RPathConfig<'_>,
libs: &[PathBuf]) -> Vec<String> {
libs.iter().map(|a| get_rpath_relative_to_output(config, a)).collect()
}

fn get_rpath_relative_to_output(config: &mut RPathConfig, lib: &Path) -> String {
fn get_rpath_relative_to_output(config: &mut RPathConfig<'_>, lib: &Path) -> String {
// Mac doesn't appear to support $ORIGIN
let prefix = if config.is_like_osx {
"@loader_path"
Expand Down Expand Up @@ -127,7 +127,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
} else {
let mut ita = path.components();
let mut itb = base.components();
let mut comps: Vec<Component> = vec![];
let mut comps: Vec<Component<'_>> = vec![];
loop {
match (ita.next(), itb.next()) {
(None, None) => break,
Expand All @@ -154,7 +154,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
}


fn get_install_prefix_rpath(config: &mut RPathConfig) -> String {
fn get_install_prefix_rpath(config: &mut RPathConfig<'_>) -> String {
let path = (config.get_install_prefix_lib_path)();
let path = env::current_dir().unwrap().join(&path);
// FIXME (#9639): This needs to handle non-utf8 paths
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn rewrite_imports(path: &Path, import_map: &FxHashMap<String, String>) {
fs::write(path, &ret.data).expect("failed to write wasm output");

fn rewrite_import_section(
wasm: &mut WasmDecoder,
wasm: &mut WasmDecoder<'_>,
import_map: &FxHashMap<String, String>,
)
-> Vec<u8>
Expand All @@ -75,7 +75,7 @@ pub fn rewrite_imports(path: &Path, import_map: &FxHashMap<String, String>) {
return dst.data
}

fn rewrite_import_entry(wasm: &mut WasmDecoder,
fn rewrite_import_entry(wasm: &mut WasmDecoder<'_>,
dst: &mut WasmEncoder,
import_map: &FxHashMap<String, String>) {
// More info about the binary format here is available at:
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn write_output_file(
}

pub fn create_target_machine(
tcx: TyCtxt,
tcx: TyCtxt<'_, '_, '_>,
find_features: bool,
) -> &'static mut llvm::TargetMachine {
target_machine_factory(tcx.sess, tcx.backend_optimization_level(LOCAL_CRATE), find_features)()
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_codegen_llvm/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,17 @@ pub fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let mono_items = cx.codegen_unit
.items_in_deterministic_order(cx.tcx);
for &(mono_item, (linkage, visibility)) in &mono_items {
mono_item.predefine::<Builder>(&cx, linkage, visibility);
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, linkage, visibility);
}

// ... and now that we have everything pre-defined, fill out those definitions.
for &(mono_item, _) in &mono_items {
mono_item.define::<Builder>(&cx);
mono_item.define::<Builder<'_, '_, '_>>(&cx);
}

// If this codegen unit contains the main function, also create the
// wrapper here
maybe_create_entry_wrapper::<Builder>(&cx);
maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&cx);

// Run replace-all-uses-with for statics that need it
for &(old_g, new_g) in cx.statics_to_rauw().borrow().iter() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
fn checked_binop(
&mut self,
oop: OverflowOp,
ty: Ty,
ty: Ty<'_>,
lhs: Self::Value,
rhs: Self::Value,
) -> (Self::Value, Self::Value) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn is_pie_binary(sess: &Session) -> bool {
}

pub unsafe fn create_module(
tcx: TyCtxt,
tcx: TyCtxt<'_, '_, '_>,
llcx: &'ll llvm::Context,
mod_name: &str,
) -> &'ll llvm::Module {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/create_scope_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use syntax_pos::BytePos;
/// If debuginfo is disabled, the returned vector is empty.
pub fn create_mir_scopes(
cx: &CodegenCx<'ll, '_>,
mir: &Mir,
mir: &Mir<'_>,
debug_context: &FunctionDebugContext<&'ll DISubprogram>,
) -> IndexVec<SourceScope, MirDebugScope<&'ll DIScope>> {
let null_scope = MirDebugScope {
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn create_mir_scopes(
}

fn make_mir_scope(cx: &CodegenCx<'ll, '_>,
mir: &Mir,
mir: &Mir<'_>,
has_variables: &BitSet<SourceScope>,
debug_context: &FunctionDebugContextData<&'ll DISubprogram>,
scope: SourceScope,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use syntax::attr;

/// Inserts a side-effect free instruction sequence that makes sure that the
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder) {
pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, '_, '_>) {
if needs_gdb_debug_scripts_section(bx) {
let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global(bx);
// Load just the first byte as that's all that's necessary to force
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
})
}

pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx) -> bool {
pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
let omit_gdb_pretty_printer_section =
attr::contains_name(&cx.tcx.hir().krate_attrs(),
"omit_gdb_pretty_printer_section");
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Hash for llvm::Metadata {
}

impl fmt::Debug for llvm::Metadata {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
(self as *const Self).fmt(f)
}
}
Expand Down Expand Up @@ -817,7 +817,7 @@ fn pointer_type_metadata(
}
}

pub fn compile_unit_metadata(tcx: TyCtxt,
pub fn compile_unit_metadata(tcx: TyCtxt<'_, '_, '_>,
codegen_unit_name: &str,
debug_context: &CrateDebugContext<'ll, '_>)
-> &'ll DIDescriptor {
Expand Down Expand Up @@ -1162,7 +1162,7 @@ fn prepare_union_metadata(
// sometimes emit the old style rather than emit something completely
// useless when rust is compiled against LLVM 6 or older. This
// function decides which representation will be emitted.
fn use_enum_fallback(cx: &CodegenCx) -> bool {
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
// On MSVC we have to use the fallback mode, because LLVM doesn't
// lower variant parts to PDB.
return cx.sess().target.target.options.is_like_msvc
Expand Down Expand Up @@ -1736,7 +1736,7 @@ fn prepare_enum_metadata(
}),
);

fn get_enum_discriminant_name(cx: &CodegenCx,
fn get_enum_discriminant_name(cx: &CodegenCx<'_, '_>,
def_id: DefId)
-> InternedString {
cx.tcx.item_name(def_id)
Expand Down Expand Up @@ -1863,7 +1863,7 @@ fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'
}
return Some(create_DIArray(DIB(cx), &[]));

fn get_parameter_names(cx: &CodegenCx,
fn get_parameter_names(cx: &CodegenCx<'_, '_>,
generics: &ty::Generics)
-> Vec<InternedString> {
let mut names = generics.parent.map_or(vec![], |def_id| {
Expand Down
Loading