Skip to content

Commit

Permalink
Auto merge of rust-lang#104387 - Manishearth:rollup-9e551p5, r=Manish…
Browse files Browse the repository at this point in the history
…earth

Rollup of 9 pull requests

Successful merges:

 - rust-lang#103709 (ci: Upgrade dist-x86_64-netbsd to NetBSD 9.0)
 - rust-lang#103744 (Upgrade cc for working is_flag_supported on cross-compiles)
 - rust-lang#104105 (llvm: dwo only emitted when object code emitted)
 - rust-lang#104158 (Return .efi extension for EFI executable)
 - rust-lang#104181 (Add a few known-bug tests)
 - rust-lang#104266 (Regression test for coercion of mut-ref to dyn-star)
 - rust-lang#104300 (Document `Path::parent` behavior around relative paths)
 - rust-lang#104304 (Enable profiler in dist-s390x-linux)
 - rust-lang#104362 (Add `delay_span_bug` to `AttrWrapper::take_for_recovery`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 14, 2022
2 parents f90a4ff + 4fdd944 commit 96ddd32
Show file tree
Hide file tree
Showing 29 changed files with 681 additions and 56 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.0.73"
version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"
dependencies = [
"jobserver",
]
Expand Down
16 changes: 13 additions & 3 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,21 @@ pub(crate) unsafe fn codegen(
drop(handlers);
}

// `.dwo` files are only emitted if:
//
// - Object files are being emitted (i.e. bitcode only or metadata only compilations will not
// produce dwarf objects, even if otherwise enabled)
// - Target supports Split DWARF
// - Split debuginfo is enabled
// - Split DWARF kind is `split` (i.e. debuginfo is split into `.dwo` files, not different
// sections in the `.o` files).
let dwarf_object_emitted = matches!(config.emit_obj, EmitObj::ObjectCode(_))
&& cgcx.target_can_use_split_dwarf
&& cgcx.split_debuginfo != SplitDebuginfo::Off
&& cgcx.split_dwarf_kind == SplitDwarfKind::Split;
Ok(module.into_compiled_module(
config.emit_obj != EmitObj::None,
cgcx.target_can_use_split_dwarf
&& cgcx.split_debuginfo != SplitDebuginfo::Off
&& cgcx.split_dwarf_kind == SplitDwarfKind::Split,
dwarf_object_emitted,
config.emit_bc,
&cgcx.output_filenames,
))
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ fn main() {
"c++"
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
// NetBSD uses a separate library when relocation is required
"stdc++_pic"
"stdc++_p"
} else if llvm_use_libcxx.is_some() {
"c++"
} else {
Expand Down
12 changes: 9 additions & 3 deletions compiler/rustc_parse/src/parser/attr_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use rustc_ast::tokenstream::{AttrTokenTree, DelimSpan, LazyAttrTokenStream, Spac
use rustc_ast::{self as ast};
use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens};
use rustc_errors::PResult;
use rustc_span::{sym, Span};
use rustc_session::parse::ParseSess;
use rustc_span::{sym, Span, DUMMY_SP};

use std::convert::TryInto;
use std::ops::Range;
Expand Down Expand Up @@ -39,8 +40,13 @@ impl AttrWrapper {
pub fn empty() -> AttrWrapper {
AttrWrapper { attrs: AttrVec::new(), start_pos: usize::MAX }
}
// FIXME: Delay span bug here?
pub(crate) fn take_for_recovery(self) -> AttrVec {

pub(crate) fn take_for_recovery(self, sess: &ParseSess) -> AttrVec {
sess.span_diagnostic.delay_span_bug(
self.attrs.get(0).map(|attr| attr.span).unwrap_or(DUMMY_SP),
"AttrVec is taken for recovery but no error is produced",
);

self.attrs
}

Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ impl<'a> Parser<'a> {
self.mk_block_err(cond_span.shrink_to_hi())
}
} else {
let attrs = self.parse_outer_attributes()?.take_for_recovery(); // For recovery.
let attrs = self.parse_outer_attributes()?; // For recovery.
let block = if self.check(&token::OpenDelim(Delimiter::Brace)) {
self.parse_block()?
} else {
Expand All @@ -2289,7 +2289,7 @@ impl<'a> Parser<'a> {
})?
}
};
self.error_on_if_block_attrs(lo, false, block.span, &attrs);
self.error_on_if_block_attrs(lo, false, block.span, attrs);
block
};
let els = if self.eat_keyword(kw::Else) { Some(self.parse_else_expr()?) } else { None };
Expand Down Expand Up @@ -2350,7 +2350,7 @@ impl<'a> Parser<'a> {
/// Parses an `else { ... }` expression (`else` token already eaten).
fn parse_else_expr(&mut self) -> PResult<'a, P<Expr>> {
let else_span = self.prev_token.span; // `else`
let attrs = self.parse_outer_attributes()?.take_for_recovery(); // For recovery.
let attrs = self.parse_outer_attributes()?; // For recovery.
let expr = if self.eat_keyword(kw::If) {
self.parse_if_expr()?
} else if self.check(&TokenKind::OpenDelim(Delimiter::Brace)) {
Expand Down Expand Up @@ -2385,7 +2385,7 @@ impl<'a> Parser<'a> {
},
}
};
self.error_on_if_block_attrs(else_span, true, expr.span, &attrs);
self.error_on_if_block_attrs(else_span, true, expr.span, attrs);
Ok(expr)
}

Expand All @@ -2394,8 +2394,13 @@ impl<'a> Parser<'a> {
ctx_span: Span,
is_ctx_else: bool,
branch_span: Span,
attrs: &[ast::Attribute],
attrs: AttrWrapper,
) {
if attrs.is_empty() {
return;
}

let attrs: &[ast::Attribute] = &attrs.take_for_recovery(self.sess);
let (attributes, last) = match attrs {
[] => return,
[x0 @ xn] | [x0, .., xn] => (x0.span.to(xn.span), xn.span),
Expand Down
12 changes: 7 additions & 5 deletions compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_ast as ast;
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter, TokenKind};
use rustc_ast::util::classify;
use rustc_ast::{AttrStyle, AttrVec, Attribute, LocalKind, MacCall, MacCallStmt, MacStmtStyle};
use rustc_ast::{AttrStyle, AttrVec, LocalKind, MacCall, MacCallStmt, MacStmtStyle};
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Stmt};
use rustc_ast::{StmtKind, DUMMY_NODE_ID};
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<'a> Parser<'a> {
self.mk_stmt(lo.to(item.span), StmtKind::Item(P(item)))
} else if self.eat(&token::Semi) {
// Do not attempt to parse an expression if we're done here.
self.error_outer_attrs(&attrs.take_for_recovery());
self.error_outer_attrs(attrs);
self.mk_stmt(lo, StmtKind::Empty)
} else if self.token != token::CloseDelim(Delimiter::Brace) {
// Remainder are line-expr stmts.
Expand All @@ -120,7 +120,7 @@ impl<'a> Parser<'a> {
}
self.mk_stmt(lo.to(e.span), StmtKind::Expr(e))
} else {
self.error_outer_attrs(&attrs.take_for_recovery());
self.error_outer_attrs(attrs);
return Ok(None);
}))
}
Expand Down Expand Up @@ -199,8 +199,10 @@ impl<'a> Parser<'a> {

/// Error on outer attributes in this context.
/// Also error if the previous token was a doc comment.
fn error_outer_attrs(&self, attrs: &[Attribute]) {
if let [.., last] = attrs {
fn error_outer_attrs(&self, attrs: AttrWrapper) {
if !attrs.is_empty()
&& let attrs = attrs.take_for_recovery(self.sess)
&& let attrs @ [.., last] = &*attrs {
if last.is_doc_comment() {
self.sess.emit_err(DocCommentDoesNotDocumentAnything {
span: last.span,
Expand Down
13 changes: 12 additions & 1 deletion library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,10 @@ impl Path {

/// Returns the `Path` without its final component, if there is one.
///
/// Returns [`None`] if the path terminates in a root or prefix.
/// This means it returns `Some("")` for relative paths with one component.
///
/// Returns [`None`] if the path terminates in a root or prefix, or if it's
/// the empty string.
///
/// # Examples
///
Expand All @@ -2156,6 +2159,14 @@ impl Path {
/// let grand_parent = parent.parent().unwrap();
/// assert_eq!(grand_parent, Path::new("/"));
/// assert_eq!(grand_parent.parent(), None);
///
/// let relative_path = Path::new("foo/bar");
/// let parent = relative_path.parent();
/// assert_eq!(parent, Some(Path::new("foo")));
/// let grand_parent = parent.and_then(Path::parent);
/// assert_eq!(grand_parent, Some(Path::new("")));
/// let great_grand_parent = grand_parent.and_then(Path::parent);
/// assert_eq!(great_grand_parent, None);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(alias = "dirname")]
Expand Down
2 changes: 1 addition & 1 deletion library/unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ compiler_builtins = "0.1.0"
cfg-if = "1.0"

[build-dependencies]
cc = "1.0.69"
cc = "1.0.76"

[features]

Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ pub use t;
/// Given an executable called `name`, return the filename for the
/// executable for a particular target.
pub fn exe(name: &str, target: TargetSelection) -> String {
if target.contains("windows") { format!("{}.exe", name) } else { name.to_string() }
if target.contains("windows") {
format!("{}.exe", name)
} else if target.contains("uefi") {
format!("{}.efi", name)
} else {
name.to_string()
}
}

/// Returns `true` if the file name given looks like a dynamic library.
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/dist-s390x-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ ENV \

ENV HOSTS=s390x-unknown-linux-gnu

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --enable-profiler --disable-docs
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
9 changes: 3 additions & 6 deletions src/ci/docker/host-x86_64/dist-x86_64-netbsd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
FROM ubuntu:16.04
FROM ubuntu:20.04

COPY scripts/cross-apt-packages.sh /scripts/
RUN sh /scripts/cross-apt-packages.sh
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y zlib1g-dev

COPY host-x86_64/dist-x86_64-netbsd/build-netbsd-toolchain.sh /tmp/
RUN /tmp/build-netbsd-toolchain.sh

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

COPY scripts/cmake.sh /scripts/
RUN /scripts/cmake.sh

ENV PATH=$PATH:/x-tools/x86_64-unknown-netbsd/bin

ENV \
Expand All @@ -21,6 +19,5 @@ ENV \

ENV HOSTS=x86_64-unknown-netbsd

ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs \
--set llvm.allow-old-toolchain
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ cd netbsd

mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot

URL=https://ci-mirrors.rust-lang.org/rustc

# Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/source/sets/*.tgz
curl $URL/2018-03-01-netbsd-src.tgz | tar xzf -
curl $URL/2018-03-01-netbsd-gnusrc.tgz | tar xzf -
curl $URL/2018-03-01-netbsd-sharesrc.tgz | tar xzf -
curl $URL/2018-03-01-netbsd-syssrc.tgz | tar xzf -

# Originally from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-$BSD/amd64/binary/sets/*.tgz
curl $URL/2018-03-01-netbsd-base.tgz | \
tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
curl $URL/2018-03-01-netbsd-comp.tgz | \
tar xzf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib
# URL=https://ci-mirrors.rust-lang.org/rustc

SOURCE_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/source/sets
curl $SOURCE_URL/src.tgz | tar xzf -
curl $SOURCE_URL/gnusrc.tgz | tar xzf -
curl $SOURCE_URL/sharesrc.tgz | tar xzf -
curl $SOURCE_URL/syssrc.tgz | tar xzf -

BINARY_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/sets
curl $BINARY_URL/base.tar.xz | \
tar xJf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
curl $BINARY_URL/comp.tar.xz | \
tar xJf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib

cd usr/src

Expand Down
31 changes: 31 additions & 0 deletions src/test/incremental/issue-101518.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// revisions: cfail1
// should-ice
// error-pattern: forcing query
// known-bug: #101518

#[derive(PartialEq, Eq)]
struct Id<'a> {
ns: &'a str,
}
fn visit_struct() {
let id = Id { ns: "random1" };
const FLAG: Id<'static> = Id {
ns: "needs_to_be_the_same",
};
match id {
FLAG => {}
_ => {}
}
}
fn visit_struct2() {
let id = Id { ns: "random2" };
const FLAG: Id<'static> = Id {
ns: "needs_to_be_the_same",
};
match id {
FLAG => {}
_ => {}
}
}

fn main() {}

0 comments on commit 96ddd32

Please sign in to comment.