Skip to content

Commit 58d8761

Browse files
committed
Auto merge of #46029 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests - Successful merges: #45951, #45973, #45984, #45993, #46005, #46010 - Failed merges:
2 parents 481b42b + d57fed8 commit 58d8761

File tree

15 files changed

+144
-190
lines changed

15 files changed

+144
-190
lines changed

Diff for: src/liballoc/borrow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<'a, B: ?Sized> Cow<'a, B>
232232
///
233233
/// assert_eq!(
234234
/// cow.into_owned(),
235-
/// Cow::Owned(String::from(s))
235+
/// String::from(s)
236236
/// );
237237
/// ```
238238
///
@@ -246,7 +246,7 @@ impl<'a, B: ?Sized> Cow<'a, B>
246246
///
247247
/// assert_eq!(
248248
/// cow.into_owned(),
249-
/// Cow::Owned(String::from(s))
249+
/// String::from(s)
250250
/// );
251251
/// ```
252252
#[stable(feature = "rust1", since = "1.0.0")]

Diff for: src/librustc/hir/check_attr.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,27 @@ struct CheckAttrVisitor<'a> {
4747

4848
impl<'a> CheckAttrVisitor<'a> {
4949
/// Check any attribute.
50-
fn check_attribute(&self, attr: &ast::Attribute, target: Target) {
50+
fn check_attribute(&self, attr: &ast::Attribute, item: &ast::Item, target: Target) {
5151
if let Some(name) = attr.name() {
5252
match &*name.as_str() {
53-
"inline" => self.check_inline(attr, target),
54-
"repr" => self.check_repr(attr, target),
53+
"inline" => self.check_inline(attr, item, target),
54+
"repr" => self.check_repr(attr, item, target),
5555
_ => (),
5656
}
5757
}
5858
}
5959

6060
/// Check if an `#[inline]` is applied to a function.
61-
fn check_inline(&self, attr: &ast::Attribute, target: Target) {
61+
fn check_inline(&self, attr: &ast::Attribute, item: &ast::Item, target: Target) {
6262
if target != Target::Fn {
6363
struct_span_err!(self.sess, attr.span, E0518, "attribute should be applied to function")
64-
.span_label(attr.span, "requires a function")
64+
.span_label(item.span, "not a function")
6565
.emit();
6666
}
6767
}
6868

6969
/// Check if an `#[repr]` attr is valid.
70-
fn check_repr(&self, attr: &ast::Attribute, target: Target) {
70+
fn check_repr(&self, attr: &ast::Attribute, item: &ast::Item, target: Target) {
7171
let words = match attr.meta_item_list() {
7272
Some(words) => words,
7373
None => {
@@ -139,7 +139,7 @@ impl<'a> CheckAttrVisitor<'a> {
139139
_ => continue,
140140
};
141141
struct_span_err!(self.sess, attr.span, E0517, "{}", message)
142-
.span_label(attr.span, format!("requires {}", label))
142+
.span_label(item.span, format!("not {}", label))
143143
.emit();
144144
}
145145
if conflicting_reprs > 1 {
@@ -153,7 +153,7 @@ impl<'a> Visitor<'a> for CheckAttrVisitor<'a> {
153153
fn visit_item(&mut self, item: &'a ast::Item) {
154154
let target = Target::from_item(item);
155155
for attr in &item.attrs {
156-
self.check_attribute(attr, target);
156+
self.check_attribute(attr, item, target);
157157
}
158158
visit::walk_item(self, item);
159159
}

Diff for: src/librustc/session/config.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1471,8 +1471,15 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
14711471
Some("human") => ErrorOutputType::HumanReadable(color),
14721472
Some("json") => ErrorOutputType::Json(false),
14731473
Some("pretty-json") => ErrorOutputType::Json(true),
1474-
Some("short") => ErrorOutputType::Short(color),
1475-
1474+
Some("short") => {
1475+
if nightly_options::is_unstable_enabled(matches) {
1476+
ErrorOutputType::Short(color)
1477+
} else {
1478+
early_error(ErrorOutputType::default(),
1479+
&format!("the `-Z unstable-options` flag must also be passed to \
1480+
enable the short error message option"));
1481+
}
1482+
}
14761483
None => ErrorOutputType::HumanReadable(color),
14771484

14781485
Some(arg) => {

Diff for: src/librustc_typeck/check/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ use std::mem::replace;
117117
use std::ops::{self, Deref};
118118
use syntax::abi::Abi;
119119
use syntax::ast;
120+
use syntax::attr;
120121
use syntax::codemap::{self, original_sp, Spanned};
121122
use syntax::feature_gate::{GateIssue, emit_feature_err};
122123
use syntax::ptr::P;
@@ -1561,12 +1562,15 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
15611562
let def = tcx.adt_def(def_id);
15621563
def.destructor(tcx); // force the destructor to be evaluated
15631564

1564-
if vs.is_empty() && tcx.has_attr(def_id, "repr") {
1565-
struct_span_err!(
1566-
tcx.sess, sp, E0084,
1567-
"unsupported representation for zero-variant enum")
1568-
.span_label(sp, "unsupported enum representation")
1569-
.emit();
1565+
if vs.is_empty() {
1566+
let attributes = tcx.get_attrs(def_id);
1567+
if let Some(attr) = attr::find_by_name(&attributes, "repr") {
1568+
struct_span_err!(
1569+
tcx.sess, attr.span, E0084,
1570+
"unsupported representation for zero-variant enum")
1571+
.span_label(sp, "zero-variant enum")
1572+
.emit();
1573+
}
15701574
}
15711575

15721576
let repr_type_ty = def.repr.discr_type().to_ty(tcx);

Diff for: src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ impl<'a> Item<'a> {
16831683
format!("{}-{}", self.item.source.loline, self.item.source.hiline)
16841684
};
16851685
Some(format!("{root}src/{krate}/{path}#{lines}",
1686-
root = root,
1686+
root = Escape(&root),
16871687
krate = krate,
16881688
path = path,
16891689
lines = lines))

Diff for: src/libsyntax/ext/expand.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use std_inject;
2929
use symbol::Symbol;
3030
use symbol::keywords;
3131
use syntax_pos::{Span, DUMMY_SP};
32+
use syntax_pos::hygiene::ExpnFormat;
3233
use tokenstream::{TokenStream, TokenTree};
3334
use util::small_vector::SmallVector;
3435
use visit::Visitor;
@@ -151,6 +152,26 @@ impl ExpansionKind {
151152
}
152153
}
153154

155+
fn macro_bang_format(path: &ast::Path) -> ExpnFormat {
156+
// We don't want to format a path using pretty-printing,
157+
// `format!("{}", path)`, because that tries to insert
158+
// line-breaks and is slow.
159+
let mut path_str = String::with_capacity(64);
160+
for (i, segment) in path.segments.iter().enumerate() {
161+
if i != 0 {
162+
path_str.push_str("::");
163+
}
164+
165+
if segment.identifier.name != keywords::CrateRoot.name() &&
166+
segment.identifier.name != keywords::DollarCrate.name()
167+
{
168+
path_str.push_str(&segment.identifier.name.as_str())
169+
}
170+
}
171+
172+
MacroBang(Symbol::intern(&path_str))
173+
}
174+
154175
pub struct Invocation {
155176
pub kind: InvocationKind,
156177
expansion_kind: ExpansionKind,
@@ -517,7 +538,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
517538
mark.set_expn_info(ExpnInfo {
518539
call_site: span,
519540
callee: NameAndSpan {
520-
format: MacroBang(Symbol::intern(&format!("{}", path))),
541+
format: macro_bang_format(path),
521542
span: def_site_span,
522543
allow_internal_unstable,
523544
allow_internal_unsafe,
@@ -564,7 +585,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
564585
invoc.expansion_data.mark.set_expn_info(ExpnInfo {
565586
call_site: span,
566587
callee: NameAndSpan {
567-
format: MacroBang(Symbol::intern(&format!("{}", path))),
588+
format: macro_bang_format(path),
568589
span: tt_span,
569590
allow_internal_unstable,
570591
allow_internal_unsafe: false,
@@ -600,7 +621,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
600621
invoc.expansion_data.mark.set_expn_info(ExpnInfo {
601622
call_site: span,
602623
callee: NameAndSpan {
603-
format: MacroBang(Symbol::intern(&format!("{}", path))),
624+
format: macro_bang_format(path),
604625
// FIXME procedural macros do not have proper span info
605626
// yet, when they do, we should use it here.
606627
span: None,

Diff for: src/test/compile-fail/E0084.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[repr(i32)]
12-
enum Foo {}
13-
//~^ ERROR E0084
14-
//~| unsupported enum representation
11+
#[repr(i32)] //~ ERROR: E0084
12+
enum Foo {} //~ NOTE: zero-variant enum
1513

1614
fn main() {
1715
}

Diff for: src/test/compile-fail/E0517.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[repr(C)] //~ ERROR E0517
12-
//~| requires a struct, enum or union
13-
type Foo = u8;
11+
#[repr(C)] //~ ERROR: E0517
12+
type Foo = u8; //~ NOTE: not a struct, enum or union
1413

15-
#[repr(packed)] //~ ERROR E0517
16-
//~| requires a struct
17-
enum Foo2 {Bar, Baz}
14+
#[repr(packed)] //~ ERROR: E0517
15+
enum Foo2 {Bar, Baz} //~ NOTE: not a struct
1816

19-
#[repr(u8)] //~ ERROR E0517
20-
//~| requires an enum
21-
struct Foo3 {bar: bool, baz: bool}
17+
#[repr(u8)] //~ ERROR: E0517
18+
struct Foo3 {bar: bool, baz: bool} //~ NOTE: not an enum
2219

23-
#[repr(C)] //~ ERROR E0517
24-
//~| requires a struct, enum or union
25-
impl Foo3 {
20+
#[repr(C)] //~ ERROR: E0517
21+
impl Foo3 { //~ NOTE: not a struct, enum or union
2622
}
2723

2824
fn main() {

Diff for: src/test/compile-fail/E0518.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[inline(always)] //~ ERROR E0518
12-
//~| requires a function
13-
struct Foo;
11+
#[inline(always)] //~ ERROR: E0518
12+
struct Foo; //~ NOTE: not a function
1413

15-
#[inline(never)] //~ ERROR E0518
16-
//~| requires a function
17-
impl Foo {
14+
#[inline(never)] //~ ERROR: E0518
15+
impl Foo { //~ NOTE: not a function
1816
}
1917

2018
fn main() {

Diff for: src/test/incremental/hashes/exported_vs_not.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ pub fn body_not_exported_to_metadata() -> u32 {
2626
}
2727

2828
#[cfg(not(cfail1))]
29-
#[rustc_clean(label="Hir", cfg="cfail2")]
30-
#[rustc_clean(label="Hir", cfg="cfail3")]
31-
#[rustc_dirty(label="HirBody", cfg="cfail2")]
32-
#[rustc_clean(label="HirBody", cfg="cfail3")]
29+
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
30+
#[rustc_clean(cfg="cfail3")]
3331
#[rustc_metadata_clean(cfg="cfail2")]
3432
#[rustc_metadata_clean(cfg="cfail3")]
3533
pub fn body_not_exported_to_metadata() -> u32 {
@@ -49,10 +47,8 @@ pub fn body_exported_to_metadata_because_of_inline() -> u32 {
4947
}
5048

5149
#[cfg(not(cfail1))]
52-
#[rustc_clean(label="Hir", cfg="cfail2")]
53-
#[rustc_clean(label="Hir", cfg="cfail3")]
54-
#[rustc_dirty(label="HirBody", cfg="cfail2")]
55-
#[rustc_clean(label="HirBody", cfg="cfail3")]
50+
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
51+
#[rustc_clean(cfg="cfail3")]
5652
#[rustc_metadata_dirty(cfg="cfail2")]
5753
#[rustc_metadata_clean(cfg="cfail3")]
5854
#[inline]
@@ -73,10 +69,8 @@ pub fn body_exported_to_metadata_because_of_generic() -> u32 {
7369
}
7470

7571
#[cfg(not(cfail1))]
76-
#[rustc_clean(label="Hir", cfg="cfail2")]
77-
#[rustc_clean(label="Hir", cfg="cfail3")]
78-
#[rustc_dirty(label="HirBody", cfg="cfail2")]
79-
#[rustc_clean(label="HirBody", cfg="cfail3")]
72+
#[rustc_clean(cfg="cfail2", except="HirBody,MirValidated,MirOptimized")]
73+
#[rustc_clean(cfg="cfail3")]
8074
#[rustc_metadata_dirty(cfg="cfail2")]
8175
#[rustc_metadata_clean(cfg="cfail3")]
8276
#[inline]

0 commit comments

Comments
 (0)