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 #58724

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
8 changes: 4 additions & 4 deletions src/librustc_codegen_llvm/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'a, 'tcx> CrateDebugContext<'a, 'tcx> {
}

/// Creates any deferred debug metadata nodes
pub fn finalize(cx: &CodegenCx) {
pub fn finalize(cx: &CodegenCx<'_, '_>) {
if cx.dbg_cx.is_none() {
return;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
instance: Instance<'tcx>,
sig: ty::FnSig<'tcx>,
llfn: &'ll Value,
mir: &mir::Mir,
mir: &mir::Mir<'_>,
) -> FunctionDebugContext<&'ll DISubprogram> {
if self.sess().opts.debuginfo == DebugInfo::None {
return FunctionDebugContext::DebugInfoDisabled;
Expand Down Expand Up @@ -455,7 +455,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
return create_DIArray(DIB(cx), &template_params[..]);
}

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 Expand Up @@ -518,7 +518,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {

fn create_mir_scopes(
&self,
mir: &mir::Mir,
mir: &mir::Mir<'_>,
debug_context: &FunctionDebugContext<&'ll DISubprogram>,
) -> IndexVec<mir::SourceScope, MirDebugScope<&'ll DIScope>> {
create_scope_map::create_mir_scopes(self, mir, debug_context)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
}
}

fn push_item_name(cx: &CodegenCx,
fn push_item_name(cx: &CodegenCx<'_, '_>,
def_id: DefId,
qualified: bool,
output: &mut String) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_codegen_ssa::traits::*;

use syntax_pos::Span;

pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool
pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool
{
// The is_local_to_unit flag indicates whether a function is local to the
// current compilation unit (i.e., if it is *static* in the C-sense). The
Expand All @@ -37,7 +37,7 @@ pub fn create_DIArray(
}

/// Returns syntax_pos::Loc corresponding to the beginning of the span
pub fn span_start(cx: &CodegenCx, span: Span) -> syntax_pos::Loc {
pub fn span_start(cx: &CodegenCx<'_, '_>, span: Span) -> syntax_pos::Loc {
cx.sess().source_map().lookup_char_pos(span.lo())
}

Expand Down
Loading