Skip to content

Commit 0e3c9bb

Browse files
committed
Auto merge of #48615 - Manishearth:rollup, r=Manishearth
Rollup of 10 pull requests - Successful merges: #48355, #48359, #48380, #48419, #48420, #48461, #48522, #48570, #48572, #48603 - Failed merges:
2 parents 0ff9872 + b2b9707 commit 0e3c9bb

File tree

41 files changed

+677
-148
lines changed

Some content is hidden

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

41 files changed

+677
-148
lines changed

src/doc/man/rustc.1

+10
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ Print version info and exit.
125125
\fB\-v\fR, \fB\-\-verbose\fR
126126
Use verbose output.
127127
.TP
128+
\fB\-\-remap\-path\-prefix\fR \fIfrom\fR=\fIto\fR
129+
Remap source path prefixes in all output, including compiler diagnostics, debug information,
130+
macro expansions, etc. The \fIfrom\fR=\fIto\fR parameter is scanned from right to left, so \fIfrom\fR
131+
may contain '=', but \fIto\fR may not.
132+
133+
This is useful for normalizing build products, for example by removing the current directory out of
134+
pathnames emitted into the object files. The replacement is purely textual, with no consideration of
135+
the current system's pathname syntax. For example \fI\-\-remap\-path\-prefix foo=bar\fR will
136+
match \fBfoo/lib.rs\fR but not \fB./foo/lib.rs\fR.
137+
.TP
128138
\fB\-\-extern\fR \fINAME\fR=\fIPATH\fR
129139
Specify where an external rust library is located. These should match
130140
\fIextern\fR declarations in the crate's source code.

src/doc/unstable-book/src/compiler-flags/remap-path-prefix.md

-37
This file was deleted.

src/libcore/iter/iterator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,8 @@ pub trait Iterator {
10621062
/// assert_eq!(merged, "alphabetagamma");
10631063
/// ```
10641064
///
1065-
/// You can also rewrite this in terms of [`flat_map()`] which is preferable
1066-
/// in this case since that conveys intent clearer:
1065+
/// You can also rewrite this in terms of [`flat_map()`], which is preferable
1066+
/// in this case since it conveys intent more clearly:
10671067
///
10681068
/// ```
10691069
/// let words = ["alpha", "beta", "gamma"];

src/libcore/panicking.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ pub fn panic_fmt(fmt: fmt::Arguments, file_line_col: &(&'static str, u32, u32))
6464
#[allow(improper_ctypes)]
6565
extern {
6666
#[lang = "panic_fmt"]
67-
#[unwind]
67+
#[cfg_attr(stage0, unwind)]
68+
#[cfg_attr(not(stage0), unwind(allowed))]
6869
fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: u32, col: u32) -> !;
6970
}
7071
let (file, line, col) = *file_line_col;

src/libpanic_unwind/gcc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ unsafe fn find_eh_action(context: *mut uw::_Unwind_Context)
286286
// See docs in the `unwind` module.
287287
#[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
288288
#[lang = "eh_unwind_resume"]
289-
#[unwind]
289+
#[cfg_attr(stage0, unwind)]
290+
#[cfg_attr(not(stage0), unwind(allowed))]
290291
unsafe extern "C" fn rust_eh_unwind_resume(panic_ctx: *mut u8) -> ! {
291292
uw::_Unwind_Resume(panic_ctx as *mut uw::_Unwind_Exception);
292293
}

src/libpanic_unwind/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ pub unsafe extern "C" fn __rust_maybe_catch_panic(f: fn(*mut u8),
112112
// Entry point for raising an exception, just delegates to the platform-specific
113113
// implementation.
114114
#[no_mangle]
115-
#[unwind]
115+
#[cfg_attr(stage0, unwind)]
116+
#[cfg_attr(not(stage0), unwind(allowed))]
116117
pub unsafe extern "C" fn __rust_start_panic(data: usize, vtable: usize) -> u32 {
117118
imp::panic(mem::transmute(raw::TraitObject {
118119
data: data as *mut (),

src/libpanic_unwind/seh64_gnu.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ unsafe extern "C" fn rust_eh_personality(exceptionRecord: *mut c::EXCEPTION_RECO
108108
}
109109

110110
#[lang = "eh_unwind_resume"]
111-
#[unwind]
111+
#[cfg_attr(stage0, unwind)]
112+
#[cfg_attr(not(stage0), unwind(allowed))]
112113
unsafe extern "C" fn rust_eh_unwind_resume(panic_ctx: c::LPVOID) -> ! {
113114
let params = [panic_ctx as c::ULONG_PTR];
114115
c::RaiseException(RUST_PANIC,

src/libpanic_unwind/windows.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,21 @@ pub enum EXCEPTION_DISPOSITION {
7979
pub use self::EXCEPTION_DISPOSITION::*;
8080

8181
extern "system" {
82-
#[unwind]
82+
#[cfg_attr(stage0, unwind)]
83+
#[cfg_attr(not(stage0), unwind(allowed))]
8384
pub fn RaiseException(dwExceptionCode: DWORD,
8485
dwExceptionFlags: DWORD,
8586
nNumberOfArguments: DWORD,
8687
lpArguments: *const ULONG_PTR);
87-
#[unwind]
88+
#[cfg_attr(stage0, unwind)]
89+
#[cfg_attr(not(stage0), unwind(allowed))]
8890
pub fn RtlUnwindEx(TargetFrame: LPVOID,
8991
TargetIp: LPVOID,
9092
ExceptionRecord: *const EXCEPTION_RECORD,
9193
ReturnValue: LPVOID,
9294
OriginalContext: *const CONTEXT,
9395
HistoryTable: *const UNWIND_HISTORY_TABLE);
94-
#[unwind]
96+
#[cfg_attr(stage0, unwind)]
97+
#[cfg_attr(not(stage0), unwind(allowed))]
9598
pub fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8);
9699
}

src/libproc_macro/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl SourceFile {
316316
/// If the code span associated with this `SourceFile` was generated by an external macro, this
317317
/// may not be an actual path on the filesystem. Use [`is_real`] to check.
318318
///
319-
/// Also note that even if `is_real` returns `true`, if `-Z remap-path-prefix-*` was passed on
319+
/// Also note that even if `is_real` returns `true`, if `--remap-path-prefix` was passed on
320320
/// the command line, the path as given may not actually be valid.
321321
///
322322
/// [`is_real`]: #method.is_real

src/librustc/hir/lowering.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use hir::HirVec;
4646
use hir::map::{Definitions, DefKey, DefPathData};
4747
use hir::def_id::{DefIndex, DefId, CRATE_DEF_INDEX, DefIndexAddressSpace};
4848
use hir::def::{Def, PathResolution};
49-
use lint::builtin::PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES;
49+
use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES};
5050
use middle::cstore::CrateStore;
5151
use rustc_data_structures::indexed_vec::IndexVec;
5252
use session::Session;
@@ -912,7 +912,11 @@ impl<'a> LoweringContext<'a> {
912912
TyKind::Path(ref qself, ref path) => {
913913
let id = self.lower_node_id(t.id);
914914
let qpath = self.lower_qpath(t.id, qself, path, ParamMode::Explicit, itctx);
915-
return self.ty_path(id, t.span, qpath);
915+
let ty = self.ty_path(id, t.span, qpath);
916+
if let hir::TyTraitObject(..) = ty.node {
917+
self.maybe_lint_bare_trait(t.span, t.id, qself.is_none() && path.is_global());
918+
}
919+
return ty;
916920
}
917921
TyKind::ImplicitSelf => {
918922
hir::TyPath(hir::QPath::Resolved(None, P(hir::Path {
@@ -931,7 +935,7 @@ impl<'a> LoweringContext<'a> {
931935
let expr = self.lower_body(None, |this| this.lower_expr(expr));
932936
hir::TyTypeof(expr)
933937
}
934-
TyKind::TraitObject(ref bounds, ..) => {
938+
TyKind::TraitObject(ref bounds, kind) => {
935939
let mut lifetime_bound = None;
936940
let bounds = bounds.iter().filter_map(|bound| {
937941
match *bound {
@@ -950,6 +954,9 @@ impl<'a> LoweringContext<'a> {
950954
let lifetime_bound = lifetime_bound.unwrap_or_else(|| {
951955
self.elided_lifetime(t.span)
952956
});
957+
if kind != TraitObjectSyntax::Dyn {
958+
self.maybe_lint_bare_trait(t.span, t.id, false);
959+
}
953960
hir::TyTraitObject(bounds, lifetime_bound)
954961
}
955962
TyKind::ImplTrait(ref bounds) => {
@@ -3685,7 +3692,6 @@ impl<'a> LoweringContext<'a> {
36853692
// The original ID is taken by the `PolyTraitRef`,
36863693
// so the `Ty` itself needs a different one.
36873694
id = self.next_id();
3688-
36893695
hir::TyTraitObject(hir_vec![principal], self.elided_lifetime(span))
36903696
} else {
36913697
hir::TyPath(hir::QPath::Resolved(None, path))
@@ -3703,6 +3709,16 @@ impl<'a> LoweringContext<'a> {
37033709
name: hir::LifetimeName::Implicit,
37043710
}
37053711
}
3712+
3713+
fn maybe_lint_bare_trait(&self, span: Span, id: NodeId, is_global: bool) {
3714+
if self.sess.features.borrow().dyn_trait {
3715+
self.sess.buffer_lint_with_diagnostic(
3716+
builtin::BARE_TRAIT_OBJECT, id, span,
3717+
"trait objects without an explicit `dyn` are deprecated",
3718+
builtin::BuiltinLintDiagnostics::BareTraitObject(span, is_global)
3719+
)
3720+
}
3721+
}
37063722
}
37073723

37083724
fn body_ids(bodies: &BTreeMap<hir::BodyId, hir::Body>) -> Vec<hir::BodyId> {

src/librustc/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
html_root_url = "https://doc.rust-lang.org/nightly/")]
4242
#![deny(warnings)]
4343

44+
#![cfg_attr(not(stage0), allow(bare_trait_object))]
45+
4446
#![feature(box_patterns)]
4547
#![feature(box_syntax)]
4648
#![feature(conservative_impl_trait)]

src/librustc/lint/builtin.rs

+37-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
//! compiler code, rather than using their own custom pass. Those
1515
//! lints are all available in `rustc_lint::builtin`.
1616
17+
use errors::DiagnosticBuilder;
1718
use lint::{LintPass, LateLintPass, LintArray};
19+
use session::Session;
20+
use session::config::Epoch;
21+
use syntax::codemap::Span;
1822

1923
declare_lint! {
2024
pub CONST_ERR,
@@ -252,6 +256,13 @@ declare_lint! {
252256
"hidden lifetime parameters are deprecated, try `Foo<'_>`"
253257
}
254258

259+
declare_lint! {
260+
pub BARE_TRAIT_OBJECT,
261+
Warn,
262+
"suggest using `dyn Trait` for trait objects",
263+
Epoch::Epoch2018
264+
}
265+
255266
/// Does nothing as a lint pass, but registers some `Lint`s
256267
/// which are used by other parts of the compiler.
257268
#[derive(Copy, Clone)]
@@ -298,10 +309,34 @@ impl LintPass for HardwiredLints {
298309
COERCE_NEVER,
299310
SINGLE_USE_LIFETIME,
300311
TYVAR_BEHIND_RAW_POINTER,
301-
ELIDED_LIFETIME_IN_PATH
302-
312+
ELIDED_LIFETIME_IN_PATH,
313+
BARE_TRAIT_OBJECT
303314
)
304315
}
305316
}
306317

318+
// this could be a closure, but then implementing derive traits
319+
// becomes hacky (and it gets allocated)
320+
#[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
321+
pub enum BuiltinLintDiagnostics {
322+
Normal,
323+
BareTraitObject(Span, /* is_global */ bool)
324+
}
325+
326+
impl BuiltinLintDiagnostics {
327+
pub fn run(self, sess: &Session, db: &mut DiagnosticBuilder) {
328+
match self {
329+
BuiltinLintDiagnostics::Normal => (),
330+
BuiltinLintDiagnostics::BareTraitObject(span, is_global) => {
331+
let sugg = match sess.codemap().span_to_snippet(span) {
332+
Ok(ref s) if is_global => format!("dyn ({})", s),
333+
Ok(s) => format!("dyn {}", s),
334+
Err(_) => format!("dyn <type>")
335+
};
336+
db.span_suggestion(span, "use `dyn`", sugg);
337+
}
338+
}
339+
}
340+
}
341+
307342
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for HardwiredLints {}

src/librustc/lint/context.rs

+39-9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use self::TargetLint::*;
2929
use std::slice;
3030
use lint::{EarlyLintPassObject, LateLintPassObject};
3131
use lint::{Level, Lint, LintId, LintPass, LintBuffer};
32+
use lint::builtin::BuiltinLintDiagnostics;
3233
use lint::levels::{LintLevelSets, LintLevelsBuilder};
3334
use middle::privacy::AccessLevels;
3435
use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
@@ -92,14 +93,19 @@ pub struct BufferedEarlyLint {
9293
pub ast_id: ast::NodeId,
9394
pub span: MultiSpan,
9495
pub msg: String,
96+
pub diagnostic: BuiltinLintDiagnostics,
9597
}
9698

9799
/// Extra information for a future incompatibility lint. See the call
98100
/// to `register_future_incompatible` in `librustc_lint/lib.rs` for
99101
/// guidelines.
100102
pub struct FutureIncompatibleInfo {
101103
pub id: LintId,
102-
pub reference: &'static str // e.g., a URL for an issue/PR/RFC or error code
104+
/// e.g., a URL for an issue/PR/RFC or error code
105+
pub reference: &'static str,
106+
/// If this is an epoch fixing lint, the epoch in which
107+
/// this lint becomes obsolete
108+
pub epoch: Option<config::Epoch>,
103109
}
104110

105111
/// The target of the `by_name` map, which accounts for renaming/deprecation.
@@ -194,11 +200,24 @@ impl LintStore {
194200
pub fn register_future_incompatible(&mut self,
195201
sess: Option<&Session>,
196202
lints: Vec<FutureIncompatibleInfo>) {
197-
let ids = lints.iter().map(|f| f.id).collect();
198-
self.register_group(sess, false, "future_incompatible", ids);
199-
for info in lints {
200-
self.future_incompatible.insert(info.id, info);
203+
204+
for epoch in config::ALL_EPOCHS {
205+
let lints = lints.iter().filter(|f| f.epoch == Some(*epoch)).map(|f| f.id)
206+
.collect::<Vec<_>>();
207+
if !lints.is_empty() {
208+
self.register_group(sess, false, epoch.lint_name(), lints)
209+
}
201210
}
211+
212+
let mut future_incompatible = vec![];
213+
for lint in lints {
214+
future_incompatible.push(lint.id);
215+
self.future_incompatible.insert(lint.id, lint);
216+
}
217+
218+
self.register_group(sess, false, "future_incompatible", future_incompatible);
219+
220+
202221
}
203222

204223
pub fn future_incompatible(&self, id: LintId) -> Option<&FutureIncompatibleInfo> {
@@ -429,6 +448,16 @@ pub trait LintContext<'tcx>: Sized {
429448
self.lookup(lint, span, msg).emit();
430449
}
431450

451+
fn lookup_and_emit_with_diagnostics<S: Into<MultiSpan>>(&self,
452+
lint: &'static Lint,
453+
span: Option<S>,
454+
msg: &str,
455+
diagnostic: BuiltinLintDiagnostics) {
456+
let mut db = self.lookup(lint, span, msg);
457+
diagnostic.run(self.sess(), &mut db);
458+
db.emit();
459+
}
460+
432461
fn lookup<S: Into<MultiSpan>>(&self,
433462
lint: &'static Lint,
434463
span: Option<S>,
@@ -499,9 +528,10 @@ impl<'a> EarlyContext<'a> {
499528

500529
fn check_id(&mut self, id: ast::NodeId) {
501530
for early_lint in self.buffered.take(id) {
502-
self.lookup_and_emit(early_lint.lint_id.lint,
503-
Some(early_lint.span.clone()),
504-
&early_lint.msg);
531+
self.lookup_and_emit_with_diagnostics(early_lint.lint_id.lint,
532+
Some(early_lint.span.clone()),
533+
&early_lint.msg,
534+
early_lint.diagnostic);
505535
}
506536
}
507537
}
@@ -1054,7 +1084,7 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) {
10541084
if !sess.opts.actually_rustdoc {
10551085
for (_id, lints) in cx.buffered.map {
10561086
for early_lint in lints {
1057-
span_bug!(early_lint.span, "failed to process buffered lint here");
1087+
sess.delay_span_bug(early_lint.span, "failed to process buffered lint here");
10581088
}
10591089
}
10601090
}

0 commit comments

Comments
 (0)