Skip to content

Commit

Permalink
Auto merge of #75126 - JohnTitor:rollup-aejluzx, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #74759 (add `unsigned_abs` to signed integers)
 - #75043 (rustc_ast: `(Nested)MetaItem::check_name` -> `has_name`)
 - #75056 (Lint path statements to suggest using drop when the type needs drop)
 - #75081 (Fix logging for rustdoc)
 - #75083 (Do not trigger `unused_braces` for `while let`)
 - #75084 (Stabilize Ident::new_raw)
 - #75103 (Disable building rust-analyzer on riscv64)
 - #75106 (Enable docs on in the x86_64-unknown-linux-musl manifest)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Aug 4, 2020
2 parents 1d601d6 + aa84a76 commit 60c2e8d
Show file tree
Hide file tree
Showing 46 changed files with 297 additions and 149 deletions.
23 changes: 23 additions & 0 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,29 @@ $EndFeature, "
}
}

doc_comment! {
concat!("Computes the absolute value of `self` without any wrapping
or panicking.
# Examples
Basic usage:
```
", $Feature, "#![feature(unsigned_abs)]
assert_eq!(100", stringify!($SelfT), ".unsigned_abs(), 100", stringify!($UnsignedT), ");
assert_eq!((-100", stringify!($SelfT), ").unsigned_abs(), 100", stringify!($UnsignedT), ");
assert_eq!((-128i8).unsigned_abs(), 128u8);",
$EndFeature, "
```"),
#[unstable(feature = "unsigned_abs", issue = "74913")]
#[inline]
pub const fn unsigned_abs(self) -> $UnsignedT {
self.wrapping_abs() as $UnsignedT
}
}

doc_comment! {
concat!("Wrapping (modular) exponentiation. Computes `self.pow(exp)`,
wrapping around at the boundary of the type.
Expand Down
7 changes: 5 additions & 2 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ impl Ident {
/// Creates a new `Ident` with the given `string` as well as the specified
/// `span`.
/// The `string` argument must be a valid identifier permitted by the
/// language, otherwise the function will panic.
/// language (including keywords, e.g. `self` or `fn`). Otherwise, the function will panic.
///
/// Note that `span`, currently in rustc, configures the hygiene information
/// for this identifier.
Expand All @@ -870,7 +870,10 @@ impl Ident {
}

/// Same as `Ident::new`, but creates a raw identifier (`r#ident`).
#[unstable(feature = "proc_macro_raw_ident", issue = "54723")]
/// The `string` argument be a valid identifier permitted by the language
/// (including keywords, e.g. `fn`). Keywords which are usable in path segments
/// (e.g. `self`, `super`) are not supported, and will cause a panic.
#[stable(feature = "proc_macro_raw_ident", since = "1.47.0")]
pub fn new_raw(string: &str, span: Span) -> Ident {
Ident(bridge::client::Ident::new(string, span.0, true))
}
Expand Down
74 changes: 47 additions & 27 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ pub struct RustAnalyzer {
}

impl Step for RustAnalyzer {
type Output = PathBuf;
type Output = Option<PathBuf>;
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand All @@ -1373,11 +1373,17 @@ impl Step for RustAnalyzer {
});
}

fn run(self, builder: &Builder<'_>) -> PathBuf {
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
let compiler = self.compiler;
let target = self.target;
assert!(builder.config.extended);

if target.contains("riscv64") {
// riscv64 currently has an LLVM bug that makes rust-analyzer unable
// to build. See #74813 for details.
return None;
}

let src = builder.src.join("src/tools/rust-analyzer");
let release_num = builder.release_num("rust-analyzer/crates/rust-analyzer");
let name = pkgname(builder, "rust-analyzer");
Expand Down Expand Up @@ -1431,7 +1437,7 @@ impl Step for RustAnalyzer {
builder.info(&format!("Dist rust-analyzer stage{} ({})", compiler.stage, target));
let _time = timeit(builder);
builder.run(&mut cmd);
distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple))
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target.triple)))
}
}

Expand Down Expand Up @@ -1789,7 +1795,7 @@ impl Step for Extended {
tarballs.push(rustc_installer);
tarballs.push(cargo_installer);
tarballs.extend(rls_installer.clone());
tarballs.push(rust_analyzer_installer.clone());
tarballs.extend(rust_analyzer_installer.clone());
tarballs.push(clippy_installer);
tarballs.extend(miri_installer.clone());
tarballs.extend(rustfmt_installer.clone());
Expand Down Expand Up @@ -1867,7 +1873,9 @@ impl Step for Extended {
if rls_installer.is_none() {
contents = filter(&contents, "rls");
}
contents = filter(&contents, "rust-analyzer");
if rust_analyzer_installer.is_none() {
contents = filter(&contents, "rust-analyzer");
}
if miri_installer.is_none() {
contents = filter(&contents, "miri");
}
Expand Down Expand Up @@ -1914,7 +1922,9 @@ impl Step for Extended {
if rls_installer.is_some() {
prepare("rls");
}
prepare("rust-analyzer");
if rust_analyzer_installer.is_some() {
prepare("rust-analyzer");
}
if miri_installer.is_some() {
prepare("miri");
}
Expand Down Expand Up @@ -1976,7 +1986,9 @@ impl Step for Extended {
if rls_installer.is_some() {
prepare("rls");
}
prepare("rust-analyzer");
if rust_analyzer_installer.is_some() {
prepare("rust-analyzer");
}
if miri_installer.is_some() {
prepare("miri");
}
Expand Down Expand Up @@ -2076,23 +2088,25 @@ impl Step for Extended {
.arg(etc.join("msi/remove-duplicates.xsl")),
);
}
builder.run(
Command::new(&heat)
.current_dir(&exe)
.arg("dir")
.arg("rust-analyzer")
.args(&heat_flags)
.arg("-cg")
.arg("RustAnalyzerGroup")
.arg("-dr")
.arg("RustAnalyzer")
.arg("-var")
.arg("var.RustAnalyzerDir")
.arg("-out")
.arg(exe.join("RustAnalyzerGroup.wxs"))
.arg("-t")
.arg(etc.join("msi/remove-duplicates.xsl")),
);
if rust_analyzer_installer.is_some() {
builder.run(
Command::new(&heat)
.current_dir(&exe)
.arg("dir")
.arg("rust-analyzer")
.args(&heat_flags)
.arg("-cg")
.arg("RustAnalyzerGroup")
.arg("-dr")
.arg("RustAnalyzer")
.arg("-var")
.arg("var.RustAnalyzerDir")
.arg("-out")
.arg(exe.join("RustAnalyzerGroup.wxs"))
.arg("-t")
.arg(etc.join("msi/remove-duplicates.xsl")),
);
}
builder.run(
Command::new(&heat)
.current_dir(&exe)
Expand Down Expand Up @@ -2186,7 +2200,9 @@ impl Step for Extended {
if rls_installer.is_some() {
cmd.arg("-dRlsDir=rls");
}
cmd.arg("-dRustAnalyzerDir=rust-analyzer");
if rust_analyzer_installer.is_some() {
cmd.arg("-dRustAnalyzerDir=rust-analyzer");
}
if miri_installer.is_some() {
cmd.arg("-dMiriDir=miri");
}
Expand All @@ -2206,7 +2222,9 @@ impl Step for Extended {
if rls_installer.is_some() {
candle("RlsGroup.wxs".as_ref());
}
candle("RustAnalyzerGroup.wxs".as_ref());
if rust_analyzer_installer.is_some() {
candle("RustAnalyzerGroup.wxs".as_ref());
}
if miri_installer.is_some() {
candle("MiriGroup.wxs".as_ref());
}
Expand Down Expand Up @@ -2244,7 +2262,9 @@ impl Step for Extended {
if rls_installer.is_some() {
cmd.arg("RlsGroup.wixobj");
}
cmd.arg("RustAnalyzerGroup.wixobj");
if rust_analyzer_installer.is_some() {
cmd.arg("RustAnalyzerGroup.wixobj");
}
if miri_installer.is_some() {
cmd.arg("MiriGroup.wixobj");
}
Expand Down
17 changes: 11 additions & 6 deletions src/librustc_ast/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ impl NestedMetaItem {
}

/// Returns `true` if this list item is a MetaItem with a name of `name`.
pub fn check_name(&self, name: Symbol) -> bool {
self.meta_item().map_or(false, |meta_item| meta_item.check_name(name))
pub fn has_name(&self, name: Symbol) -> bool {
self.meta_item().map_or(false, |meta_item| meta_item.has_name(name))
}

/// For a single-segment meta item, returns its name; otherwise, returns `None`.
Expand Down Expand Up @@ -173,8 +173,13 @@ impl Attribute {
}
}

/// Returns `true` if the attribute's path matches the argument. If it matches, then the
/// attribute is marked as used.
/// Returns `true` if the attribute's path matches the argument.
/// If it matches, then the attribute is marked as used.
/// Should only be used by rustc, other tools can use `has_name` instead,
/// because only rustc is supposed to report the `unused_attributes` lint.
/// `MetaItem` and `NestedMetaItem` are produced by "lowering" an `Attribute`
/// and don't have identity, so they only has the `has_name` method,
/// and you need to mark the original `Attribute` as used when necessary.
pub fn check_name(&self, name: Symbol) -> bool {
let matches = self.has_name(name);
if matches {
Expand Down Expand Up @@ -278,7 +283,7 @@ impl MetaItem {
}
}

pub fn check_name(&self, name: Symbol) -> bool {
pub fn has_name(&self, name: Symbol) -> bool {
self.path == name
}

Expand Down Expand Up @@ -405,7 +410,7 @@ pub fn mk_doc_comment(style: AttrStyle, comment: Symbol, span: Span) -> Attribut
}

pub fn list_contains_name(items: &[NestedMetaItem], name: Symbol) -> bool {
items.iter().any(|item| item.check_name(name))
items.iter().any(|item| item.has_name(name))
}

pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_ast_passes/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
if attr.check_name(sym::doc) {
for nested_meta in attr.meta_item_list().unwrap_or_default() {
macro_rules! gate_doc { ($($name:ident => $feature:ident)*) => {
$(if nested_meta.check_name(sym::$name) {
$(if nested_meta.has_name(sym::$name) {
let msg = concat!("`#[doc(", stringify!($name), ")]` is experimental");
gate_feature_post!(self, $feature, attr.span, msg);
})*
Expand Down Expand Up @@ -314,7 +314,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::ItemKind::Struct(..) => {
for attr in attr::filter_by_name(&i.attrs[..], sym::repr) {
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
if item.check_name(sym::simd) {
if item.has_name(sym::simd) {
gate_feature_post!(
&self,
repr_simd,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_attr/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op
if let Some(meta) = attr.meta() {
if let MetaItemKind::List(items) = meta.kind {
if items.len() == 1 {
if items[0].check_name(sym::allowed) {
if items[0].has_name(sym::allowed) {
return Some(UnwindAttr::Allowed);
} else if items[0].check_name(sym::aborts) {
} else if items[0].has_name(sym::aborts) {
return Some(UnwindAttr::Aborts);
}
}
Expand Down Expand Up @@ -168,7 +168,7 @@ pub fn contains_feature_attr(attrs: &[Attribute], feature_name: Symbol) -> bool
item.check_name(sym::feature)
&& item
.meta_item_list()
.map(|list| list.iter().any(|mi| mi.is_word() && mi.check_name(feature_name)))
.map(|list| list.iter().any(|mi| mi.is_word() && mi.has_name(feature_name)))
.unwrap_or(false)
})
}
Expand Down Expand Up @@ -505,7 +505,7 @@ pub fn cfg_matches(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Feat
}

fn try_gate_cfg(cfg: &ast::MetaItem, sess: &ParseSess, features: Option<&Features>) {
let gate = find_gated_cfg(|sym| cfg.check_name(sym));
let gate = find_gated_cfg(|sym| cfg.has_name(sym));
if let (Some(feats), Some(gated_cfg)) = (features, gate) {
gate_cfg(&gated_cfg, cfg.span, sess, feats);
}
Expand Down Expand Up @@ -898,7 +898,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
}
} else {
if let Some(meta_item) = item.meta_item() {
if meta_item.check_name(sym::align) {
if meta_item.has_name(sym::align) {
if let MetaItemKind::NameValue(ref value) = meta_item.kind {
recognised = true;
let mut err = struct_span_err!(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/proc_macro_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a> CollectProcMacros<'a> {

let attributes_attr = list.get(1);
let proc_attrs: Vec<_> = if let Some(attr) = attributes_attr {
if !attr.check_name(sym::attributes) {
if !attr.has_name(sym::attributes) {
self.handler.span_err(attr.span(), "second argument must be `attributes`")
}
attr.meta_item_list()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
Some(list) => {
let msg = list
.iter()
.find(|mi| mi.check_name(sym::expected))
.find(|mi| mi.has_name(sym::expected))
.and_then(|mi| mi.meta_item())
.and_then(|mi| mi.value_str());
if list.len() != 1 || msg.is_none() {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_expand/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,14 +1644,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
}

if let Some(list) = at.meta_item_list() {
if !list.iter().any(|it| it.check_name(sym::include)) {
if !list.iter().any(|it| it.has_name(sym::include)) {
return noop_visit_attribute(at, self);
}

let mut items = vec![];

for mut it in list {
if !it.check_name(sym::include) {
if !it.has_name(sym::include) {
items.push({
noop_visit_meta_list_item(&mut it, self);
it
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl AssertModuleSource<'tcx> {

fn field(&self, attr: &ast::Attribute, name: Symbol) -> Symbol {
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
if item.check_name(name) {
if item.has_name(name) {
if let Some(value) = item.value_str() {
return value;
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_incremental/persist/dirty_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl DirtyCleanVisitor<'tcx> {

fn labels(&self, attr: &Attribute) -> Option<Labels> {
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
if item.check_name(LABEL) {
if item.has_name(LABEL) {
let value = expect_associated_value(self.tcx, &item);
return Some(self.resolve_labels(&item, value));
}
Expand All @@ -242,7 +242,7 @@ impl DirtyCleanVisitor<'tcx> {
/// `except=` attribute value
fn except(&self, attr: &Attribute) -> Labels {
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
if item.check_name(EXCEPT) {
if item.has_name(EXCEPT) {
let value = expect_associated_value(self.tcx, &item);
return self.resolve_labels(&item, value);
}
Expand Down Expand Up @@ -474,15 +474,15 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
debug!("check_config: config={:?}", config);
let (mut cfg, mut except, mut label) = (None, false, false);
for item in attr.meta_item_list().unwrap_or_else(Vec::new) {
if item.check_name(CFG) {
if item.has_name(CFG) {
let value = expect_associated_value(tcx, &item);
debug!("check_config: searching for cfg {:?}", value);
cfg = Some(config.contains(&(value, None)));
}
if item.check_name(LABEL) {
if item.has_name(LABEL) {
label = true;
}
if item.check_name(EXCEPT) {
if item.has_name(EXCEPT) {
except = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ fn has_doc(attr: &ast::Attribute) -> bool {

if let Some(list) = attr.meta_item_list() {
for meta in list {
if meta.check_name(sym::include) || meta.check_name(sym::hidden) {
if meta.has_name(sym::include) || meta.has_name(sym::hidden) {
return true;
}
}
Expand Down
Loading

0 comments on commit 60c2e8d

Please sign in to comment.