Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #88366

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
da25af2
Make spans for tuple patterns in E0023 more precise
camelid Aug 17, 2021
f1e8607
Don't stabilize creation of TryReserveError instances
kornelski Aug 21, 2021
d0b482a
Add more tuple pattern too many fields test cases
camelid Aug 18, 2021
0fa3b4f
Make E0023 spans even more precise
camelid Aug 18, 2021
02ed23c
Use an exhaustive match in `Node::ident()` and add docs
camelid Aug 18, 2021
08ceac8
Add cross-crate tuple field count error test
camelid Aug 21, 2021
19f4510
Bless tests
camelid Aug 22, 2021
f28793d
Feat: added inline asm support for s390x
Sl1mb0 Aug 6, 2021
5f5afba
Feat: added s390x reg-definitions, constraint codes, and tests
Sl1mb0 Aug 18, 2021
7095dff
Refactor: added #[no_mangle]
Sl1mb0 Aug 18, 2021
66e95b1
Fix: moved #[no_mangle]
Sl1mb0 Aug 18, 2021
eeb0b52
Feat: further testing & support for i64 general register use
Sl1mb0 Aug 22, 2021
0c9e23c
Fix: appeased x.py test tidy --bless
Sl1mb0 Aug 22, 2021
0ac601d
Mach-O (Macos/ios/...) LLD flavor is always LD64.
hkratz Aug 23, 2021
a519095
Include ld64 nexte to ld for use with -Z gcc-ld
hkratz Aug 23, 2021
0f7702e
Pass -fuse-ld=/path/to/ld64 if -Z gcc-ld and the lld_flavor for the t…
hkratz Aug 23, 2021
820e268
handle ascription type op in NLL HRTB diagnostics
lqd Aug 23, 2021
05cd587
Refactor: disabled frame pointer; consolidated unsupported register e…
Sl1mb0 Aug 23, 2021
a9f6237
Fix: made suggested change
Sl1mb0 Aug 23, 2021
7b0e564
Update NLL HRTB type ascription blessed expectations
lqd Aug 23, 2021
96381d3
Fix: added necessary prefix
Sl1mb0 Aug 24, 2021
07d3729
Update cargo
ehuss Aug 24, 2021
4d8d72f
Handle match with non axhaustive variants in closures
roxelo Aug 24, 2021
1335b4c
Add additional match test case
roxelo Aug 24, 2021
68b1bfc
Create a specific match folder for match tests
roxelo Aug 24, 2021
4a9ba65
Feat: added explicit register tests; added prefix to check_reg asm st…
Sl1mb0 Aug 24, 2021
a216d66
type_implements_trait consider obligation failure on overflow
arora-aman Aug 25, 2021
d7d122f
update docs for `type_implements_trait`
nikomatsakis Aug 25, 2021
88bcd44
trailing whitespace
nikomatsakis Aug 25, 2021
0a42dfc
Fix debugger stepping behavior around `match` expressions
wesleywiser Jul 23, 2021
8a6501d
Adjust spans
camelid Aug 25, 2021
5df5659
Revert "Add type of a let tait test impl trait straight in let"
spastorino Aug 25, 2021
84a2661
Add test for stepping though `match` expressions
wesleywiser Aug 6, 2021
118df1c
Adjust linking order of static nobundle libraries
12101111 Aug 22, 2021
4924e34
Add argument types tait tests
spastorino Aug 25, 2021
027db5d
RustWrapper: adapt to LLVM change 0f45c16f2caa
durin42 Aug 24, 2021
6768a2d
Rollup merge of #87832 - wesleywiser:fix_match_step, r=davidtwco
Dylan-DPC Aug 26, 2021
cfe4446
Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank
Dylan-DPC Aug 26, 2021
9a9af0d
Rollup merge of #88216 - kornelski:from_layout_err, r=kennytm
Dylan-DPC Aug 26, 2021
fa8d153
Rollup merge of #88227 - 12101111:nobundle-link-order, r=petrochenkov
Dylan-DPC Aug 26, 2021
689ec97
Rollup merge of #88245 - Sl1mb0:s390-asm, r=Amanieu
Dylan-DPC Aug 26, 2021
5fb3ca9
Rollup merge of #88250 - rusticstuff:macos-lld, r=nagisa
Dylan-DPC Aug 26, 2021
246b0cd
Rollup merge of #88270 - lqd:hrtb-type-ascription, r=nikomatsakis
Dylan-DPC Aug 26, 2021
76db2ab
Rollup merge of #88278 - ehuss:update-cargo, r=ehuss
Dylan-DPC Aug 26, 2021
a4527ed
Rollup merge of #88280 - sexxi-goose:non-exhaustive, r=nikomatsakis
Dylan-DPC Aug 26, 2021
bc669ac
Rollup merge of #88289 - durin42:llvm-14-attrs, r=nikic
Dylan-DPC Aug 26, 2021
b6c5f72
Rollup merge of #88320 - sexxi-goose:issue-88103, r=nikomatsakis
Dylan-DPC Aug 26, 2021
41fbafa
Rollup merge of #88332 - spastorino:argument-types-tait-test, r=oli-obk
Dylan-DPC Aug 26, 2021
ea8f66f
Rollup merge of #88346 - spastorino:revert-type-of-a-let2, r=jackh726
Dylan-DPC Aug 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,9 @@ dependencies = [

[[package]]
name = "curl-sys"
version = "0.4.44+curl-7.77.0"
version = "0.4.45+curl-7.78.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b6d85e9322b193f117c966e79c2d6929ec08c02f339f950044aba12e20bbaf1"
checksum = "de9e5a72b1c744eb5dd20b2be4d7eb84625070bb5c4ab9b347b70464ab1e62eb"
dependencies = [
"cc",
"libc",
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {}
InlineAsmArch::Hexagon => {}
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {}
InlineAsmArch::S390x => {}
InlineAsmArch::SpirV => {}
InlineAsmArch::Wasm32 => {}
InlineAsmArch::Bpf => {}
Expand Down Expand Up @@ -633,6 +634,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>)
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r",
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::wreg) => "w",
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => "f",
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
Expand Down Expand Up @@ -711,6 +714,7 @@ fn modifier_to_llvm(
}
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => None,
InlineAsmRegClass::Bpf(_) => None,
InlineAsmRegClass::S390x(_) => None,
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
Expand Down Expand Up @@ -769,6 +773,8 @@ fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => cx.type_i64(),
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::wreg) => cx.type_i32(),
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => cx.type_f64(),
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
Expand Down
116 changes: 66 additions & 50 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1803,15 +1803,16 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
add_local_native_libraries(cmd, sess, codegen_results);
}

// Rust libraries.
// Upstream rust libraries and their nobundle static libraries
add_upstream_rust_crates::<B>(cmd, sess, codegen_results, crate_type, tmpdir);

// Native libraries linked with `#[link]` attributes at and `-l` command line options.
// Upstream dymamic native libraries linked with `#[link]` attributes at and `-l`
// command line options.
// If -Zlink-native-libraries=false is set, then the assumption is that an
// external build system already has the native dependencies defined, and it
// will provide them to the linker itself.
if sess.opts.debugging_opts.link_native_libraries {
add_upstream_native_libraries(cmd, sess, codegen_results, crate_type);
add_upstream_native_libraries(cmd, sess, codegen_results);
}

// Library linking above uses some global state for things like `-Bstatic`/`-Bdynamic` to make
Expand Down Expand Up @@ -2033,7 +2034,7 @@ fn add_local_native_libraries(
}
}

/// # Rust Crate linking
/// # Linking Rust crates and their nobundle static libraries
///
/// Rust crates are not considered at all when creating an rlib output. All dependencies will be
/// linked when producing the final output (instead of the intermediate rlib version).
Expand Down Expand Up @@ -2138,6 +2139,29 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
Linkage::NotLinked | Linkage::IncludedFromDylib => {}
Linkage::Static => {
add_static_crate::<B>(cmd, sess, codegen_results, tmpdir, crate_type, cnum);

// Link static native libs with "-bundle" modifier only if the crate they originate from
// is being linked statically to the current crate. If it's linked dynamically
// or is an rlib already included via some other dylib crate, the symbols from
// native libs will have already been included in that dylib.
//
// If -Zlink-native-libraries=false is set, then the assumption is that an
// external build system already has the native dependencies defined, and it
// will provide them to the linker itself.
if sess.opts.debugging_opts.link_native_libraries {
// Skip if this library is the same as the last.
let mut last = None;
for lib in &codegen_results.crate_info.native_libraries[&cnum] {
if lib.name.is_some()
&& relevant_lib(sess, lib)
&& matches!(lib.kind, NativeLibKind::Static { bundle: Some(false), .. })
&& last != lib.name
{
cmd.link_staticlib(lib.name.unwrap(), lib.verbatim.unwrap_or(false));
last = lib.name;
}
}
}
}
Linkage::Dynamic => add_dynamic_crate(cmd, sess, &src.dylib.as_ref().unwrap().0),
}
Expand Down Expand Up @@ -2310,27 +2334,9 @@ fn add_upstream_native_libraries(
cmd: &mut dyn Linker,
sess: &Session,
codegen_results: &CodegenResults,
crate_type: CrateType,
) {
// Be sure to use a topological sorting of crates because there may be
// interdependencies between native libraries. When passing -nodefaultlibs,
// for example, almost all native libraries depend on libc, so we have to
// make sure that's all the way at the right (liblibc is near the base of
// the dependency chain).
//
// This passes RequireStatic, but the actual requirement doesn't matter,
// we're just getting an ordering of crate numbers, we're not worried about
// the paths.
let (_, data) = codegen_results
.crate_info
.dependency_formats
.iter()
.find(|(ty, _)| *ty == crate_type)
.expect("failed to find crate type in dependency format list");

let crates = &codegen_results.crate_info.used_crates;
let mut last = (NativeLibKind::Unspecified, None);
for &cnum in crates {
for &cnum in &codegen_results.crate_info.used_crates {
for lib in codegen_results.crate_info.native_libraries[&cnum].iter() {
let name = match lib.name {
Some(l) => l,
Expand All @@ -2352,19 +2358,10 @@ fn add_upstream_native_libraries(
NativeLibKind::Framework { as_needed } => {
cmd.link_framework(name, as_needed.unwrap_or(true))
}
NativeLibKind::Static { bundle: Some(false), .. } => {
// Link "static-nobundle" native libs only if the crate they originate from
// is being linked statically to the current crate. If it's linked dynamically
// or is an rlib already included via some other dylib crate, the symbols from
// native libs will have already been included in that dylib.
if data[cnum.as_usize() - 1] == Linkage::Static {
cmd.link_staticlib(name, verbatim)
}
}
// ignore statically included native libraries here as we've
// already included them when we included the rust library
// previously
NativeLibKind::Static { bundle: None | Some(true), .. } => {}
// ignore static native libraries here as we've
// already included them in add_local_native_libraries and
// add_upstream_rust_crates
NativeLibKind::Static { .. } => {}
NativeLibKind::RawDylib => {}
}
}
Expand Down Expand Up @@ -2485,20 +2482,39 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
if let LinkerFlavor::Gcc = flavor {
match ld_impl {
LdImpl::Lld => {
let tools_path =
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
let lld_path = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
.find(|p| {
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists()
})
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
cmd.cmd().arg({
let mut arg = OsString::from("-B");
arg.push(lld_path);
arg
});
if sess.target.lld_flavor == LldFlavor::Ld64 {
let tools_path =
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
let ld64_exe = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
.map(|p| {
p.join(if sess.host.is_like_windows { "ld64.exe" } else { "ld64" })
})
.find(|p| p.exists())
.unwrap_or_else(|| sess.fatal("rust-lld (as ld64) not found"));
cmd.cmd().arg({
let mut arg = OsString::from("-fuse-ld=");
arg.push(ld64_exe);
arg
});
} else {
let tools_path =
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
let lld_path = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
.find(|p| {
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" })
.exists()
})
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
cmd.cmd().arg({
let mut arg = OsString::from("-B");
arg.push(lld_path);
arg
});
}
}
}
} else {
Expand Down
35 changes: 33 additions & 2 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3183,6 +3183,20 @@ pub enum Node<'hir> {
}

impl<'hir> Node<'hir> {
/// Get the identifier of this `Node`, if applicable.
///
/// # Edge cases
///
/// Calling `.ident()` on a [`Node::Ctor`] will return `None`
/// because `Ctor`s do not have identifiers themselves.
/// Instead, call `.ident()` on the parent struct/variant, like so:
///
/// ```ignore (illustrative)
/// ctor
/// .ctor_hir_id()
/// .and_then(|ctor_id| tcx.hir().find(tcx.hir().get_parent_node(ctor_id)))
/// .and_then(|parent| parent.ident())
/// ```
pub fn ident(&self) -> Option<Ident> {
match self {
Node::TraitItem(TraitItem { ident, .. })
Expand All @@ -3191,8 +3205,25 @@ impl<'hir> Node<'hir> {
| Node::Field(FieldDef { ident, .. })
| Node::Variant(Variant { ident, .. })
| Node::MacroDef(MacroDef { ident, .. })
| Node::Item(Item { ident, .. }) => Some(*ident),
_ => None,
| Node::Item(Item { ident, .. })
| Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
Node::Lifetime(lt) => Some(lt.name.ident()),
Node::GenericParam(p) => Some(p.name.ident()),
Node::Param(..)
| Node::AnonConst(..)
| Node::Expr(..)
| Node::Stmt(..)
| Node::Block(..)
| Node::Ctor(..)
| Node::Pat(..)
| Node::Binding(..)
| Node::Arm(..)
| Node::Local(..)
| Node::Visibility(..)
| Node::Crate(..)
| Node::Ty(..)
| Node::TraitRef(..)
| Node::Infer(..) => None,
}
}

Expand Down
23 changes: 9 additions & 14 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,34 +270,30 @@ extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn, unsigned Index,
LLVMRustAttribute RustAttr) {
Function *A = unwrap<Function>(Fn);
Attribute Attr = Attribute::get(A->getContext(), fromRust(RustAttr));
AttrBuilder B(Attr);
A->addAttributes(Index, B);
A->addAttribute(Index, Attr);
}

extern "C" void LLVMRustAddAlignmentAttr(LLVMValueRef Fn,
unsigned Index,
uint32_t Bytes) {
Function *A = unwrap<Function>(Fn);
AttrBuilder B;
B.addAlignmentAttr(Bytes);
A->addAttributes(Index, B);
A->addAttribute(Index, Attribute::getWithAlignment(
A->getContext(), llvm::Align(Bytes)));
}

extern "C" void LLVMRustAddDereferenceableAttr(LLVMValueRef Fn, unsigned Index,
uint64_t Bytes) {
Function *A = unwrap<Function>(Fn);
AttrBuilder B;
B.addDereferenceableAttr(Bytes);
A->addAttributes(Index, B);
A->addAttribute(Index, Attribute::getWithDereferenceableBytes(A->getContext(),
Bytes));
}

extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn,
unsigned Index,
uint64_t Bytes) {
Function *A = unwrap<Function>(Fn);
AttrBuilder B;
B.addDereferenceableOrNullAttr(Bytes);
A->addAttributes(Index, B);
A->addAttribute(Index, Attribute::getWithDereferenceableOrNullBytes(
A->getContext(), Bytes));
}

extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index,
Expand All @@ -323,9 +319,8 @@ extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
const char *Name,
const char *Value) {
Function *F = unwrap<Function>(Fn);
AttrBuilder B;
B.addAttribute(Name, Value);
F->addAttributes(Index, B);
F->addAttribute(Index, Attribute::get(
F->getContext(), StringRef(Name), StringRef(Value)));
}

extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc_span::Span;
use rustc_trait_selection::traits::query::type_op;
use rustc_trait_selection::traits::{SelectionContext, TraitEngineExt as _};
use rustc_traits::type_op_prove_predicate_with_span;
use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_span};

use std::fmt;
use std::rc::Rc;
Expand Down Expand Up @@ -104,10 +104,11 @@ impl<'tcx, T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx> ToUniverseInfo<'t
impl<'tcx> ToUniverseInfo<'tcx>
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>
{
fn to_universe_info(self, _base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
// Ascribe user type isn't usually called on types that have different
// bound regions.
UniverseInfo::other()
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(AscribeUserTypeQuery {
canonical_query: self,
base_universe,
})))
}
}

Expand Down Expand Up @@ -267,6 +268,37 @@ where
}
}

struct AscribeUserTypeQuery<'tcx> {
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>,
base_universe: ty::UniverseIndex,
}

impl TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
// and is only the fallback when the nice error fails. Consider improving this some more.
tcx.sess.struct_span_err(span, "higher-ranked lifetime error")
}

fn base_universe(&self) -> ty::UniverseIndex {
self.base_universe
}

fn nice_error(
&self,
tcx: TyCtxt<'tcx>,
span: Span,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx>> {
tcx.infer_ctxt().enter_with_canonical(span, &self.canonical_query, |ref infcx, key, _| {
let mut fulfill_cx = <dyn TraitEngine<'_>>::new(tcx);
type_op_ascribe_user_type_with_span(infcx, &mut *fulfill_cx, key, Some(span)).ok()?;
try_extract_error_from_fulfill_cx(fulfill_cx, infcx, placeholder_region, error_region)
})
}
}

fn try_extract_error_from_fulfill_cx<'tcx>(
mut fulfill_cx: Box<dyn TraitEngine<'tcx> + 'tcx>,
infcx: &InferCtxt<'_, 'tcx>,
Expand Down
Loading