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 11 pull requests #81733

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a072ecb
Don't build remote-test-server with the stage0 toolchain
Jan 20, 2021
b5482a8
Preserve existing LD_LIBRARY_PATH in remote-test-server
Jan 20, 2021
3f679fe
Fix rustc sysroot in systems using CAS
rcvalle Nov 21, 2020
5882cce
Expose correct symlink API on WASI
RReverser Jan 30, 2021
b6b897b
introduce future-compatibility warning for forbidden lint groups
nikomatsakis Jan 30, 2021
6e6608d
Add additional benchmarks to bit_set
JulianKnodt Feb 2, 2021
fba747a
Refactor out PrimitiveTypeTable
camsteffen Feb 2, 2021
f66115d
Use PrimTy in builtin type shadow lint
camsteffen Feb 2, 2021
4d1efb7
OsStr eq_ignore_ascii_case takes arg by value
TyPR124 Feb 3, 2021
1578f2e
Keep old symlink; expose new symlink_path
RReverser Feb 3, 2021
f4b1bef
Restore comment as it was
RReverser Feb 3, 2021
82914a5
Add more information to the error code for 'crate not found'
jyn514 Feb 2, 2021
3719247
move test to be with the others
mark-i-m Feb 3, 2021
8988238
Revert stabilizing integer::BITS.
m-ou-se Feb 3, 2021
a616f82
Add lint for `panic!(123)` which is not accepted in Rust 2021.
m-ou-se Feb 1, 2021
34d5ac2
Make panic/assert calls in rustc compatible with Rust 2021.
m-ou-se Feb 1, 2021
e9ad5be
Allow/fix non_fmt_panic in tests.
m-ou-se Feb 1, 2021
753b0b0
Update panic!() documentation about non-string panics.
m-ou-se Feb 2, 2021
3f3eb89
Fix/allow non_fmt_panic in clippy tests.
m-ou-se Feb 2, 2021
0870c15
Suggest panic!("{}", ..) instead of panic!(..) clippy::expect_fun_call.
m-ou-se Feb 3, 2021
47dd875
Rollup merge of #79253 - rcvalle:fix-rustc-sysroot-cas, r=nagisa
Dylan-DPC Feb 3, 2021
2cc747c
Rollup merge of #81456 - Amanieu:remote-test-server, r=Amanieu
Dylan-DPC Feb 3, 2021
5c7aa5a
Rollup merge of #81542 - RReverser:wasi-symlink, r=alexcrichton
Dylan-DPC Feb 3, 2021
2071f89
Rollup merge of #81556 - nikomatsakis:forbidden-lint-groups-lint, r=p…
Dylan-DPC Feb 3, 2021
f52080c
Rollup merge of #81645 - m-ou-se:panic-lint, r=estebank,flip1995
Dylan-DPC Feb 3, 2021
788016a
Rollup merge of #81676 - jyn514:crate-not-found, r=oli-obk
Dylan-DPC Feb 3, 2021
a361abb
Rollup merge of #81680 - camsteffen:primty, r=oli-obk
Dylan-DPC Feb 3, 2021
4ee4b03
Rollup merge of #81682 - JulianKnodt:bit_set_iter_benchmarks, r=oli-obk
Dylan-DPC Feb 3, 2021
9711b2f
Rollup merge of #81710 - TyPR124:patch-2, r=m-ou-se
Dylan-DPC Feb 3, 2021
36bf7ab
Rollup merge of #81725 - mark-i-m:mv-test, r=Mark-Simulacrum
Dylan-DPC Feb 3, 2021
6876aba
Rollup merge of #81727 - m-ou-se:unstabilize-bits, r=Mark-Simulacrum
Dylan-DPC Feb 3, 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/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub trait ExpectOne<A: Array> {

impl<A: Array> ExpectOne<A> for SmallVec<A> {
fn expect_one(self, err: &'static str) -> A::Item {
assert!(self.len() == 1, err);
assert!(self.len() == 1, "{}", err);
self.into_iter().next().unwrap()
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#![feature(unboxed_closures)]
#![feature(generator_trait)]
#![feature(fn_traits)]
#![feature(int_bits_const)]
#![feature(min_specialization)]
#![feature(auto_traits)]
#![feature(nll)]
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0463.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,24 @@ extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
You need to link your code to the relevant crate in order to be able to use it
(through Cargo or the `-L` option of rustc example). Plugins are crates as
well, and you link to them the same way.

## Common causes

- The crate is not present at all. If using Cargo, add it to `[dependencies]`
in Cargo.toml.
- The crate is present, but under a different name. If using Cargo, look for
`package = ` under `[dependencies]` in Cargo.toml.

## Common causes for missing `std` or `core`

- You are cross-compiling for a target which doesn't have `std` prepackaged.
Consider one of the following:
+ Adding a pre-compiled version of std with `rustup target add`
+ Building std from source with `cargo build -Z build-std`
+ Using `#![no_std]` at the crate root, so you won't need `std` in the first
place.
- You are developing the compiler itself and haven't built libstd from source.
You can usually build it with `x.py build library/std`. More information
about x.py is available in the [rustc-dev-guide].

[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ impl HandlerInner {

fn span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) -> ! {
self.emit_diag_at_span(Diagnostic::new(Bug, msg), sp);
panic!(ExplicitBug);
panic::panic_any(ExplicitBug);
}

fn emit_diag_at_span(&mut self, mut diag: Diagnostic, sp: impl Into<MultiSpan>) {
Expand Down Expand Up @@ -955,7 +955,7 @@ impl HandlerInner {

fn bug(&mut self, msg: &str) -> ! {
self.emit_diagnostic(&Diagnostic::new(Bug, msg));
panic!(ExplicitBug);
panic::panic_any(ExplicitBug);
}

fn delay_as_bug(&mut self, diagnostic: Diagnostic) {
Expand Down
49 changes: 49 additions & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,28 @@ pub enum PrimTy {
}

impl PrimTy {
/// All of the primitive types
pub const ALL: [Self; 17] = [
// any changes here should also be reflected in `PrimTy::from_name`
Self::Int(IntTy::I8),
Self::Int(IntTy::I16),
Self::Int(IntTy::I32),
Self::Int(IntTy::I64),
Self::Int(IntTy::I128),
Self::Int(IntTy::Isize),
Self::Uint(UintTy::U8),
Self::Uint(UintTy::U16),
Self::Uint(UintTy::U32),
Self::Uint(UintTy::U64),
Self::Uint(UintTy::U128),
Self::Uint(UintTy::Usize),
Self::Float(FloatTy::F32),
Self::Float(FloatTy::F64),
Self::Bool,
Self::Char,
Self::Str,
];

pub fn name_str(self) -> &'static str {
match self {
PrimTy::Int(i) => i.name_str(),
Expand All @@ -2078,6 +2100,33 @@ impl PrimTy {
PrimTy::Char => sym::char,
}
}

/// Returns the matching `PrimTy` for a `Symbol` such as "str" or "i32".
/// Returns `None` if no matching type is found.
pub fn from_name(name: Symbol) -> Option<Self> {
let ty = match name {
// any changes here should also be reflected in `PrimTy::ALL`
sym::i8 => Self::Int(IntTy::I8),
sym::i16 => Self::Int(IntTy::I16),
sym::i32 => Self::Int(IntTy::I32),
sym::i64 => Self::Int(IntTy::I64),
sym::i128 => Self::Int(IntTy::I128),
sym::isize => Self::Int(IntTy::Isize),
sym::u8 => Self::Uint(UintTy::U8),
sym::u16 => Self::Uint(UintTy::U16),
sym::u32 => Self::Uint(UintTy::U32),
sym::u64 => Self::Uint(UintTy::U64),
sym::u128 => Self::Uint(UintTy::U128),
sym::usize => Self::Uint(UintTy::Usize),
sym::f32 => Self::Float(FloatTy::F32),
sym::f64 => Self::Float(FloatTy::F64),
sym::bool => Self::Bool,
sym::char => Self::Char,
sym::str => Self::Str,
_ => return None,
};
Some(ty)
}
}

#[derive(Debug, HashStable_Generic)]
Expand Down
34 changes: 34 additions & 0 deletions compiler/rustc_index/src/bit_set/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::*;

extern crate test;
use std::hint::black_box;
use test::Bencher;

#[test]
Expand Down Expand Up @@ -364,3 +365,36 @@ fn union_hybrid_sparse_full_small_domain(b: &mut Bencher) {
sparse.union(&dense);
})
}

#[bench]
fn bench_insert(b: &mut Bencher) {
let mut bs = BitSet::new_filled(99999usize);
b.iter(|| {
black_box(bs.insert(black_box(100u32)));
});
}

#[bench]
fn bench_remove(b: &mut Bencher) {
let mut bs = BitSet::new_filled(99999usize);
b.iter(|| {
black_box(bs.remove(black_box(100u32)));
});
}

#[bench]
fn bench_iter(b: &mut Bencher) {
let bs = BitSet::new_filled(99999usize);
b.iter(|| {
bs.iter().map(|b: usize| black_box(b)).for_each(drop);
});
}

#[bench]
fn bench_intersect(b: &mut Bencher) {
let mut ba: BitSet<u32> = BitSet::new_filled(99999usize);
let bb = BitSet::new_filled(99999usize);
b.iter(|| {
ba.intersect(black_box(&bb));
});
}
15 changes: 15 additions & 0 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use rustc_session::SessionLintStore;
use rustc_span::lev_distance::find_best_match_for_name;
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
use rustc_target::abi::LayoutOf;
use tracing::debug;

use std::cell::Cell;
use std::slice;
Expand Down Expand Up @@ -336,6 +337,20 @@ impl LintStore {
}
}

/// True if this symbol represents a lint group name.
pub fn is_lint_group(&self, lint_name: Symbol) -> bool {
debug!(
"is_lint_group(lint_name={:?}, lint_groups={:?})",
lint_name,
self.lint_groups.keys().collect::<Vec<_>>()
);
let lint_name_str = &*lint_name.as_str();
self.lint_groups.contains_key(&lint_name_str) || {
let warnings_name_str = crate::WARNINGS.name_lower();
lint_name_str == &*warnings_name_str
}
}

/// Checks the name of a lint for its existence, and whether it was
/// renamed or removed. Generates a DiagnosticBuilder containing a
/// warning for renamed and removed lints. This is over both lint
Expand Down
101 changes: 73 additions & 28 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_ast::attr;
use rustc_ast::unwrap_or;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Applicability};
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_hir::{intravisit, HirId};
Expand All @@ -17,11 +17,15 @@ use rustc_middle::lint::{
};
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint::{builtin, Level, Lint, LintId};
use rustc_session::lint::{
builtin::{self, FORBIDDEN_LINT_GROUPS},
Level, Lint, LintId,
};
use rustc_session::parse::feature_err;
use rustc_session::Session;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::{source_map::MultiSpan, Span, DUMMY_SP};
use tracing::debug;

use std::cmp;

Expand Down Expand Up @@ -51,6 +55,7 @@ pub struct LintLevelsBuilder<'s> {
id_to_set: FxHashMap<HirId, u32>,
cur: u32,
warn_about_weird_lints: bool,
store: &'s LintStore,
}

pub struct BuilderPush {
Expand All @@ -59,13 +64,14 @@ pub struct BuilderPush {
}

impl<'s> LintLevelsBuilder<'s> {
pub fn new(sess: &'s Session, warn_about_weird_lints: bool, store: &LintStore) -> Self {
pub fn new(sess: &'s Session, warn_about_weird_lints: bool, store: &'s LintStore) -> Self {
let mut builder = LintLevelsBuilder {
sess,
sets: LintLevelSets::new(),
cur: 0,
id_to_set: Default::default(),
warn_about_weird_lints,
store,
};
builder.process_command_line(sess, store);
assert_eq!(builder.sets.list.len(), 1);
Expand Down Expand Up @@ -120,36 +126,75 @@ impl<'s> LintLevelsBuilder<'s> {
if let (Level::Forbid, old_src) =
self.sets.get_lint_level(id.lint, self.cur, Some(&specs), &self.sess)
{
let mut diag_builder = struct_span_err!(
self.sess,
src.span(),
E0453,
"{}({}) incompatible with previous forbid",
level.as_str(),
src.name(),
// Backwards compatibility check:
//
// We used to not consider `forbid(lint_group)`
// as preventing `allow(lint)` for some lint `lint` in
// `lint_group`. For now, issue a future-compatibility
// warning for this case.
let id_name = id.lint.name_lower();
let fcw_warning = match old_src {
LintLevelSource::Default => false,
LintLevelSource::Node(symbol, _, _) => self.store.is_lint_group(symbol),
LintLevelSource::CommandLine(symbol, _) => self.store.is_lint_group(symbol),
};
debug!(
"fcw_warning={:?}, specs.get(&id) = {:?}, old_src={:?}, id_name={:?}",
fcw_warning, specs, old_src, id_name
);
diag_builder.span_label(src.span(), "overruled by previous forbid");
match old_src {
LintLevelSource::Default => {
diag_builder.note(&format!(
"`forbid` lint level is the default for {}",
id.to_string()
));
}
LintLevelSource::Node(_, forbid_source_span, reason) => {
diag_builder.span_label(forbid_source_span, "`forbid` level set here");
if let Some(rationale) = reason {
diag_builder.note(&rationale.as_str());

let decorate_diag_builder = |mut diag_builder: DiagnosticBuilder<'_>| {
diag_builder.span_label(src.span(), "overruled by previous forbid");
match old_src {
LintLevelSource::Default => {
diag_builder.note(&format!(
"`forbid` lint level is the default for {}",
id.to_string()
));
}
LintLevelSource::Node(_, forbid_source_span, reason) => {
diag_builder.span_label(forbid_source_span, "`forbid` level set here");
if let Some(rationale) = reason {
diag_builder.note(&rationale.as_str());
}
}
LintLevelSource::CommandLine(_, _) => {
diag_builder.note("`forbid` lint level was set on command line");
}
}
LintLevelSource::CommandLine(_, _) => {
diag_builder.note("`forbid` lint level was set on command line");
}
diag_builder.emit();
};
if !fcw_warning {
let diag_builder = struct_span_err!(
self.sess,
src.span(),
E0453,
"{}({}) incompatible with previous forbid",
level.as_str(),
src.name(),
);
decorate_diag_builder(diag_builder);
} else {
self.struct_lint(
FORBIDDEN_LINT_GROUPS,
Some(src.span().into()),
|diag_builder| {
let diag_builder = diag_builder.build(&format!(
"{}({}) incompatible with previous forbid",
level.as_str(),
src.name(),
));
decorate_diag_builder(diag_builder);
},
);
}
diag_builder.emit();

// Retain the forbid lint level
return;
// Retain the forbid lint level, unless we are
// issuing a FCW. In the FCW case, we want to
// respect the new setting.
if !fcw_warning {
return;
}
}
}
specs.insert(id, (level, src));
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ mod late;
mod levels;
mod methods;
mod non_ascii_idents;
mod non_fmt_panic;
mod nonstandard_style;
mod panic_fmt;
mod passes;
mod redundant_semicolon;
mod traits;
Expand All @@ -81,8 +81,8 @@ use builtin::*;
use internal::*;
use methods::*;
use non_ascii_idents::*;
use non_fmt_panic::NonPanicFmt;
use nonstandard_style::*;
use panic_fmt::PanicFmt;
use redundant_semicolon::*;
use traits::*;
use types::*;
Expand Down Expand Up @@ -169,7 +169,7 @@ macro_rules! late_lint_passes {
ClashingExternDeclarations: ClashingExternDeclarations::new(),
DropTraitConstraints: DropTraitConstraints,
TemporaryCStringAsPtr: TemporaryCStringAsPtr,
PanicFmt: PanicFmt,
NonPanicFmt: NonPanicFmt,
]
);
};
Expand Down
Loading