Skip to content

Commit f5c81e0

Browse files
committed
Auto merge of #66944 - Centril:rollup-ojsszx6, r=Centril
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
2 parents 4007d4e + cd47551 commit f5c81e0

File tree

73 files changed

+585
-742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+585
-742
lines changed

src/doc/rustc/src/lints/listing/warn-by-default.md

-12
Original file line numberDiff line numberDiff line change
@@ -307,18 +307,6 @@ warning: path statement with no effect
307307
|
308308
```
309309

310-
## plugin-as-library
311-
312-
This lint detects when compiler plugins are used as ordinary library in
313-
non-plugin crate. Some example code that triggers this lint:
314-
315-
```rust,ignore
316-
#![feature(plugin)]
317-
#![plugin(macro_crate_test)]
318-
319-
extern crate macro_crate_test;
320-
```
321-
322310
## private-in-public
323311

324312
This lint detects private items in public interfaces not caught by the old implementation. Some

src/doc/unstable-book/src/language-features/plugin.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@ the crate attribute `#![plugin(...)]`. See the
2121
`rustc_driver::plugin` documentation for more about the
2222
mechanics of defining and loading a plugin.
2323

24-
If present, arguments passed as `#![plugin(foo(... args ...))]` are not
25-
interpreted by rustc itself. They are provided to the plugin through the
26-
`Registry`'s `args` method.
27-
2824
In the vast majority of cases, a plugin should *only* be used through
2925
`#![plugin]` and not through an `extern crate` item. Linking a plugin would
3026
pull in all of libsyntax and librustc as dependencies of your crate. This is
31-
generally unwanted unless you are building another plugin. The
32-
`plugin_as_library` lint checks these guidelines.
27+
generally unwanted unless you are building another plugin.
3328

3429
The usual practice is to put compiler plugins in their own crate, separate from
3530
any `macro_rules!` macros or ordinary Rust code meant to be used by consumers

src/librustc/lint/context.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ use rustc_error_codes::*;
4747
/// This is basically the subset of `Context` that we can
4848
/// build early in the compile pipeline.
4949
pub struct LintStore {
50-
/// Registered lints. The bool is true if the lint was
51-
/// added by a plugin.
50+
/// Registered lints.
5251
lints: Vec<&'static Lint>,
5352

5453
/// Constructor functions for each variety of lint pass.

src/librustc/mir/interpret/error.rs

+12-16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_target::spec::abi::Abi;
1414
use syntax_pos::{Pos, Span};
1515
use syntax::symbol::Symbol;
1616
use hir::GeneratorKind;
17-
use std::{fmt, env};
17+
use std::{fmt, env, any::Any};
1818

1919
use rustc_error_codes::*;
2020

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

47-
#[derive(Clone, Debug)]
47+
#[derive(Debug)]
4848
pub struct ConstEvalErr<'tcx> {
4949
pub span: Span,
5050
pub error: crate::mir::interpret::InterpError<'tcx>,
5151
pub stacktrace: Vec<FrameInfo<'tcx>>,
5252
}
5353

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

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

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

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

614610
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
@@ -634,8 +630,8 @@ impl fmt::Debug for InterpError<'_> {
634630
write!(f, "{:?}", msg),
635631
Panic(ref msg) =>
636632
write!(f, "{:?}", msg),
637-
Exit(code) =>
638-
write!(f, "exited with status code {}", code),
633+
MachineStop(_) =>
634+
write!(f, "machine caused execution to stop"),
639635
}
640636
}
641637
}

src/librustc/mir/mod.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ pub struct Body<'tcx> {
104104
/// and used for debuginfo. Indexed by a `SourceScope`.
105105
pub source_scopes: IndexVec<SourceScope, SourceScopeData>,
106106

107-
/// Crate-local information for each source scope, that can't (and
108-
/// needn't) be tracked across crates.
109-
pub source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
110-
111107
/// The yield type of the function, if it is a generator.
112108
pub yield_ty: Option<Ty<'tcx>>,
113109

@@ -167,7 +163,6 @@ impl<'tcx> Body<'tcx> {
167163
pub fn new(
168164
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
169165
source_scopes: IndexVec<SourceScope, SourceScopeData>,
170-
source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,
171166
local_decls: LocalDecls<'tcx>,
172167
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
173168
arg_count: usize,
@@ -188,7 +183,6 @@ impl<'tcx> Body<'tcx> {
188183
phase: MirPhase::Build,
189184
basic_blocks,
190185
source_scopes,
191-
source_scope_local_data,
192186
yield_ty: None,
193187
generator_drop: None,
194188
generator_layout: None,
@@ -435,6 +429,13 @@ pub enum ClearCrossCrate<T> {
435429
}
436430

437431
impl<T> ClearCrossCrate<T> {
432+
pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> {
433+
match self {
434+
ClearCrossCrate::Clear => ClearCrossCrate::Clear,
435+
ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v),
436+
}
437+
}
438+
438439
pub fn assert_crate_local(self) -> T {
439440
match self {
440441
ClearCrossCrate::Clear => bug!("unwrapping cross-crate data"),
@@ -2027,6 +2028,10 @@ rustc_index::newtype_index! {
20272028
pub struct SourceScopeData {
20282029
pub span: Span,
20292030
pub parent_scope: Option<SourceScope>,
2031+
2032+
/// Crate-local information for this source scope, that can't (and
2033+
/// needn't) be tracked across crates.
2034+
pub local_data: ClearCrossCrate<SourceScopeLocalData>,
20302035
}
20312036

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

2311-
AggregateKind::Closure(def_id, _) => ty::tls::with(|tcx| {
2316+
AggregateKind::Closure(def_id, substs) => ty::tls::with(|tcx| {
23122317
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
23132318
let name = if tcx.sess.opts.debugging_opts.span_free_formats {
2314-
format!("[closure@{:?}]", hir_id)
2319+
let substs = tcx.lift(&substs).unwrap();
2320+
format!(
2321+
"[closure@{}]",
2322+
tcx.def_path_str_with_substs(def_id, substs),
2323+
)
23152324
} else {
23162325
format!("[closure@{:?}]", tcx.hir().span(hir_id))
23172326
};

src/librustc/mir/visit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ macro_rules! make_mir_visitor {
317317
let SourceScopeData {
318318
span,
319319
parent_scope,
320+
local_data: _,
320321
} = scope_data;
321322

322323
self.visit_span(span);

src/librustc/session/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1364,8 +1364,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13641364
"enable queries of the dependency graph for regression testing"),
13651365
no_analysis: bool = (false, parse_bool, [UNTRACKED],
13661366
"parse and expand the source, but run no analysis"),
1367-
extra_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1368-
"load extra plugins"),
13691367
unstable_options: bool = (false, parse_bool, [UNTRACKED],
13701368
"adds unstable command line options to rustc interface"),
13711369
force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],

src/librustc/session/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ pub struct Session {
7676
/// (sub)diagnostics that have been set once, but should not be set again,
7777
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
7878
pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
79-
pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
8079
pub crate_types: Once<Vec<config::CrateType>>,
8180
/// The `crate_disambiguator` is constructed out of all the `-C metadata`
8281
/// arguments passed to the compiler. Its value together with the crate-name
@@ -1149,7 +1148,6 @@ fn build_session_(
11491148
local_crate_source_file,
11501149
working_dir,
11511150
one_time_diagnostics: Default::default(),
1152-
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
11531151
crate_types: Once::new(),
11541152
crate_disambiguator: Once::new(),
11551153
features: Once::new(),

src/librustc/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ pub trait PrettyPrinter<'tcx>:
682682
// FIXME(eddyb) should use `def_span`.
683683
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(did) {
684684
if self.tcx().sess.opts.debugging_opts.span_free_formats {
685-
p!(write("@{:?}", hir_id));
685+
p!(write("@"), print_def_path(did, substs));
686686
} else {
687687
p!(write("@{:?}", self.tcx().hir().span(hir_id)));
688688
}

src/librustc/ty/structural_impls.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! hand, though we've recently added some macros and proc-macros to help with the tedium.
44
55
use crate::hir::def::Namespace;
6+
use crate::hir::def_id::CRATE_DEF_INDEX;
67
use crate::mir::ProjectionKind;
78
use crate::mir::interpret;
89
use crate::ty::{self, Lift, Ty, TyCtxt, InferConst};
@@ -95,8 +96,11 @@ impl fmt::Debug for ty::BoundRegion {
9596
match *self {
9697
ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
9798
ty::BrNamed(did, name) => {
98-
write!(f, "BrNamed({:?}:{:?}, {})",
99-
did.krate, did.index, name)
99+
if did.index == CRATE_DEF_INDEX {
100+
write!(f, "BrNamed({})", name)
101+
} else {
102+
write!(f, "BrNamed({:?}, {})", did, name)
103+
}
100104
}
101105
ty::BrEnv => write!(f, "BrEnv"),
102106
}

src/librustc_codegen_llvm/back/write.rs

-14
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,6 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
365365

366366
add_sanitizer_passes(config, &mut extra_passes);
367367

368-
for pass_name in &cgcx.plugin_passes {
369-
if let Some(pass) = find_pass(pass_name) {
370-
extra_passes.push(pass);
371-
} else {
372-
diag_handler.err(&format!("a plugin asked for LLVM pass \
373-
`{}` but LLVM does not \
374-
recognize it", pass_name));
375-
}
376-
377-
if pass_name == "name-anon-globals" {
378-
have_name_anon_globals_pass = true;
379-
}
380-
}
381-
382368
// Some options cause LLVM bitcode to be emitted, which uses ThinLTOBuffers, so we need
383369
// to make sure we run LLVM's NameAnonGlobals pass when emitting bitcode; otherwise
384370
// we'll get errors in LLVM.

src/librustc_codegen_llvm/llvm_util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ const ARM_WHITELIST: &[(&str, Option<Symbol>)] = &[
108108
("rclass", Some(sym::arm_target_feature)),
109109
("dsp", Some(sym::arm_target_feature)),
110110
("neon", Some(sym::arm_target_feature)),
111+
("crc", Some(sym::arm_target_feature)),
112+
("crypto", Some(sym::arm_target_feature)),
111113
("v5te", Some(sym::arm_target_feature)),
112114
("v6", Some(sym::arm_target_feature)),
113115
("v6k", Some(sym::arm_target_feature)),

src/librustc_codegen_ssa/back/write.rs

-3
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
231231
pub total_cgus: usize,
232232
// Handler to use for diagnostics produced during codegen.
233233
pub diag_emitter: SharedEmitter,
234-
// LLVM passes added by plugins.
235-
pub plugin_passes: Vec<String>,
236234
// LLVM optimizations for which we want to print remarks.
237235
pub remark: Passes,
238236
// Worker thread number
@@ -1028,7 +1026,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
10281026
time_passes: sess.time_extended(),
10291027
prof: sess.prof.clone(),
10301028
exported_symbols,
1031-
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
10321029
remark: sess.opts.cg.remark.clone(),
10331030
worker: 0,
10341031
incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()),

src/librustc_feature/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
283283
)
284284
),
285285
(
286-
sym::plugin, CrateLevel, template!(List: "name|name(args)"),
286+
sym::plugin, CrateLevel, template!(List: "name"),
287287
Gated(
288288
Stability::Deprecated(
289289
"https://github.com/rust-lang/rust/pull/64675",

0 commit comments

Comments
 (0)