Skip to content

Commit

Permalink
Auto merge of #66944 - Centril:rollup-ojsszx6, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - #66346 (Replace .unwrap() with ? in std::os::unix::net)
 - #66789 (rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.)
 - #66850 (rustc: hide HirId's fmt::Debug output from -Z span_free_formats.)
 - #66905 (rustc_plugin: Remove some remaining plugin features)
 - #66907 (rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.)
 - #66918 (Add crc and crypto to target feature whitelist on arm)
 - #66926 (add reusable MachineStop variant to Miri engine error enum)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Dec 2, 2019
2 parents 4007d4e + cd47551 commit f5c81e0
Show file tree
Hide file tree
Showing 73 changed files with 585 additions and 742 deletions.
12 changes: 0 additions & 12 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,6 @@ warning: path statement with no effect
|
```

## plugin-as-library

This lint detects when compiler plugins are used as ordinary library in
non-plugin crate. Some example code that triggers this lint:

```rust,ignore
#![feature(plugin)]
#![plugin(macro_crate_test)]
extern crate macro_crate_test;
```

## private-in-public

This lint detects private items in public interfaces not caught by the old implementation. Some
Expand Down
7 changes: 1 addition & 6 deletions src/doc/unstable-book/src/language-features/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ the crate attribute `#![plugin(...)]`. See the
`rustc_driver::plugin` documentation for more about the
mechanics of defining and loading a plugin.

If present, arguments passed as `#![plugin(foo(... args ...))]` are not
interpreted by rustc itself. They are provided to the plugin through the
`Registry`'s `args` method.

In the vast majority of cases, a plugin should *only* be used through
`#![plugin]` and not through an `extern crate` item. Linking a plugin would
pull in all of libsyntax and librustc as dependencies of your crate. This is
generally unwanted unless you are building another plugin. The
`plugin_as_library` lint checks these guidelines.
generally unwanted unless you are building another plugin.

The usual practice is to put compiler plugins in their own crate, separate from
any `macro_rules!` macros or ordinary Rust code meant to be used by consumers
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ use rustc_error_codes::*;
/// This is basically the subset of `Context` that we can
/// build early in the compile pipeline.
pub struct LintStore {
/// Registered lints. The bool is true if the lint was
/// added by a plugin.
/// Registered lints.
lints: Vec<&'static Lint>,

/// Constructor functions for each variety of lint pass.
Expand Down
28 changes: 12 additions & 16 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_target::spec::abi::Abi;
use syntax_pos::{Pos, Span};
use syntax::symbol::Symbol;
use hir::GeneratorKind;
use std::{fmt, env};
use std::{fmt, env, any::Any};

use rustc_error_codes::*;

Expand Down Expand Up @@ -44,14 +44,14 @@ CloneTypeFoldableImpls! {
pub type ConstEvalRawResult<'tcx> = Result<RawConst<'tcx>, ErrorHandled>;
pub type ConstEvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ErrorHandled>;

#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct ConstEvalErr<'tcx> {
pub span: Span,
pub error: crate::mir::interpret::InterpError<'tcx>,
pub stacktrace: Vec<FrameInfo<'tcx>>,
}

#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct FrameInfo<'tcx> {
/// This span is in the caller.
pub call_site: Span,
Expand Down Expand Up @@ -138,6 +138,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
lint_root: Option<hir::HirId>,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
let must_error = match self.error {
InterpError::MachineStop(_) => bug!("CTFE does not stop"),
err_inval!(Layout(LayoutError::Unknown(_))) |
err_inval!(TooGeneric) =>
return Err(ErrorHandled::TooGeneric),
Expand Down Expand Up @@ -189,7 +190,7 @@ pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'
/// Thsese should always be constructed by calling `.into()` on
/// a `InterpError`. In `librustc_mir::interpret`, we have `throw_err_*`
/// macros for this.
#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct InterpErrorInfo<'tcx> {
pub kind: InterpError<'tcx>,
backtrace: Option<Box<Backtrace>>,
Expand Down Expand Up @@ -331,7 +332,6 @@ impl<O: fmt::Debug> fmt::Debug for PanicInfo<O> {
/// Error information for when the program we executed turned out not to actually be a valid
/// program. This cannot happen in stand-alone Miri, but it can happen during CTFE/ConstProp
/// where we work on generic code or execution does not have all information available.
#[derive(Clone, HashStable)]
pub enum InvalidProgramInfo<'tcx> {
/// Resolution can fail if we are in a too generic context.
TooGeneric,
Expand Down Expand Up @@ -361,7 +361,6 @@ impl fmt::Debug for InvalidProgramInfo<'tcx> {
}

/// Error information for when the program caused Undefined Behavior.
#[derive(Clone, HashStable)]
pub enum UndefinedBehaviorInfo {
/// Free-form case. Only for errors that are never caught!
Ub(String),
Expand Down Expand Up @@ -394,7 +393,6 @@ impl fmt::Debug for UndefinedBehaviorInfo {
///
/// Currently, we also use this as fall-back error kind for errors that have not been
/// categorized yet.
#[derive(Clone, HashStable)]
pub enum UnsupportedOpInfo<'tcx> {
/// Free-form case. Only for errors that are never caught!
Unsupported(String),
Expand Down Expand Up @@ -571,7 +569,6 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {

/// Error information for when the program exhausted the resources granted to it
/// by the interpreter.
#[derive(Clone, HashStable)]
pub enum ResourceExhaustionInfo {
/// The stack grew too big.
StackFrameLimitReached,
Expand All @@ -592,7 +589,6 @@ impl fmt::Debug for ResourceExhaustionInfo {
}
}

#[derive(Clone, HashStable)]
pub enum InterpError<'tcx> {
/// The program panicked.
Panic(PanicInfo<u64>),
Expand All @@ -601,14 +597,14 @@ pub enum InterpError<'tcx> {
/// The program did something the interpreter does not support (some of these *might* be UB
/// but the interpreter is not sure).
Unsupported(UnsupportedOpInfo<'tcx>),
/// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
/// The program was invalid (ill-typed, bad MIR, not sufficiently monomorphized, ...).
InvalidProgram(InvalidProgramInfo<'tcx>),
/// The program exhausted the interpreter's resources (stack/heap too big,
/// execution takes too long, ..).
/// execution takes too long, ...).
ResourceExhaustion(ResourceExhaustionInfo),
/// Not actually an interpreter error -- used to signal that execution has exited
/// with the given status code. Used by Miri, but not by CTFE.
Exit(i32),
/// Stop execution for a machine-controlled reason. This is never raised by
/// the core engine itself.
MachineStop(Box<dyn Any + Send>),
}

pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
Expand All @@ -634,8 +630,8 @@ impl fmt::Debug for InterpError<'_> {
write!(f, "{:?}", msg),
Panic(ref msg) =>
write!(f, "{:?}", msg),
Exit(code) =>
write!(f, "exited with status code {}", code),
MachineStop(_) =>
write!(f, "machine caused execution to stop"),
}
}
}
25 changes: 17 additions & 8 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ pub struct Body<'tcx> {
/// and used for debuginfo. Indexed by a `SourceScope`.
pub source_scopes: IndexVec<SourceScope, SourceScopeData>,

/// Crate-local information for each source scope, that can't (and
/// needn't) be tracked across crates.
pub source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,

/// The yield type of the function, if it is a generator.
pub yield_ty: Option<Ty<'tcx>>,

Expand Down Expand Up @@ -167,7 +163,6 @@ impl<'tcx> Body<'tcx> {
pub fn new(
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
source_scopes: IndexVec<SourceScope, SourceScopeData>,
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
local_decls: LocalDecls<'tcx>,
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
arg_count: usize,
Expand All @@ -188,7 +183,6 @@ impl<'tcx> Body<'tcx> {
phase: MirPhase::Build,
basic_blocks,
source_scopes,
source_scope_local_data,
yield_ty: None,
generator_drop: None,
generator_layout: None,
Expand Down Expand Up @@ -435,6 +429,13 @@ pub enum ClearCrossCrate<T> {
}

impl<T> ClearCrossCrate<T> {
pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> {
match self {
ClearCrossCrate::Clear => ClearCrossCrate::Clear,
ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v),
}
}

pub fn assert_crate_local(self) -> T {
match self {
ClearCrossCrate::Clear => bug!("unwrapping cross-crate data"),
Expand Down Expand Up @@ -2027,6 +2028,10 @@ rustc_index::newtype_index! {
pub struct SourceScopeData {
pub span: Span,
pub parent_scope: Option<SourceScope>,

/// Crate-local information for this source scope, that can't (and
/// needn't) be tracked across crates.
pub local_data: ClearCrossCrate<SourceScopeLocalData>,
}

#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
Expand Down Expand Up @@ -2308,10 +2313,14 @@ impl<'tcx> Debug for Rvalue<'tcx> {
}
}

AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
AggregateKind::Closure(def_id, substs) => ty::tls::with(|tcx| {
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
let name = if tcx.sess.opts.debugging_opts.span_free_formats {
format!("[closure@{:?}]", hir_id)
let substs = tcx.lift(&substs).unwrap();
format!(
"[closure@{}]",
tcx.def_path_str_with_substs(def_id, substs),
)
} else {
format!("[closure@{:?}]", tcx.hir().span(hir_id))
};
Expand Down
1 change: 1 addition & 0 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ macro_rules! make_mir_visitor {
let SourceScopeData {
span,
parent_scope,
local_data: _,
} = scope_data;

self.visit_span(span);
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1364,8 +1364,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"enable queries of the dependency graph for regression testing"),
no_analysis: bool = (false, parse_bool, [UNTRACKED],
"parse and expand the source, but run no analysis"),
extra_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
"load extra plugins"),
unstable_options: bool = (false, parse_bool, [UNTRACKED],
"adds unstable command line options to rustc interface"),
force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pub struct Session {
/// (sub)diagnostics that have been set once, but should not be set again,
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
pub crate_types: Once<Vec<config::CrateType>>,
/// The `crate_disambiguator` is constructed out of all the `-C metadata`
/// arguments passed to the compiler. Its value together with the crate-name
Expand Down Expand Up @@ -1149,7 +1148,6 @@ fn build_session_(
local_crate_source_file,
working_dir,
one_time_diagnostics: Default::default(),
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
crate_types: Once::new(),
crate_disambiguator: Once::new(),
features: Once::new(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ pub trait PrettyPrinter<'tcx>:
// FIXME(eddyb) should use `def_span`.
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(did) {
if self.tcx().sess.opts.debugging_opts.span_free_formats {
p!(write("@{:?}", hir_id));
p!(write("@"), print_def_path(did, substs));
} else {
p!(write("@{:?}", self.tcx().hir().span(hir_id)));
}
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! hand, though we've recently added some macros and proc-macros to help with the tedium.

use crate::hir::def::Namespace;
use crate::hir::def_id::CRATE_DEF_INDEX;
use crate::mir::ProjectionKind;
use crate::mir::interpret;
use crate::ty::{self, Lift, Ty, TyCtxt, InferConst};
Expand Down Expand Up @@ -95,8 +96,11 @@ impl fmt::Debug for ty::BoundRegion {
match *self {
ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
ty::BrNamed(did, name) => {
write!(f, "BrNamed({:?}:{:?}, {})",
did.krate, did.index, name)
if did.index == CRATE_DEF_INDEX {
write!(f, "BrNamed({})", name)
} else {
write!(f, "BrNamed({:?}, {})", did, name)
}
}
ty::BrEnv => write!(f, "BrEnv"),
}
Expand Down
14 changes: 0 additions & 14 deletions src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,6 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,

add_sanitizer_passes(config, &mut extra_passes);

for pass_name in &cgcx.plugin_passes {
if let Some(pass) = find_pass(pass_name) {
extra_passes.push(pass);
} else {
diag_handler.err(&format!("a plugin asked for LLVM pass \
`{}` but LLVM does not \
recognize it", pass_name));
}

if pass_name == "name-anon-globals" {
have_name_anon_globals_pass = true;
}
}

// Some options cause LLVM bitcode to be emitted, which uses ThinLTOBuffers, so we need
// to make sure we run LLVM's NameAnonGlobals pass when emitting bitcode; otherwise
// we'll get errors in LLVM.
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_codegen_llvm/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ const ARM_WHITELIST: &[(&str, Option<Symbol>)] = &[
("rclass", Some(sym::arm_target_feature)),
("dsp", Some(sym::arm_target_feature)),
("neon", Some(sym::arm_target_feature)),
("crc", Some(sym::arm_target_feature)),
("crypto", Some(sym::arm_target_feature)),
("v5te", Some(sym::arm_target_feature)),
("v6", Some(sym::arm_target_feature)),
("v6k", Some(sym::arm_target_feature)),
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
pub total_cgus: usize,
// Handler to use for diagnostics produced during codegen.
pub diag_emitter: SharedEmitter,
// LLVM passes added by plugins.
pub plugin_passes: Vec<String>,
// LLVM optimizations for which we want to print remarks.
pub remark: Passes,
// Worker thread number
Expand Down Expand Up @@ -1028,7 +1026,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
time_passes: sess.time_extended(),
prof: sess.prof.clone(),
exported_symbols,
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
remark: sess.opts.cg.remark.clone(),
worker: 0,
incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_feature/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
)
),
(
sym::plugin, CrateLevel, template!(List: "name|name(args)"),
sym::plugin, CrateLevel, template!(List: "name"),
Gated(
Stability::Deprecated(
"https://github.com/rust-lang/rust/pull/64675",
Expand Down
Loading

0 comments on commit f5c81e0

Please sign in to comment.