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 12 pull requests #73680

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a816ca
Cleanup MinGW LLVM linkage workaround
mati865 Jun 19, 2020
8d0e882
Fix handling of reserved registers for ARM inline asm
Amanieu Jun 21, 2020
a98868d
Update asm! documentation
Amanieu Jun 21, 2020
314e621
Liballoc minor hash import tweak
pickfire Jun 22, 2020
9766a93
Document the mod keyword
poliorcetics Jun 22, 2020
0a454e5
Add UI test for issue 73592
nbdd0121 Jun 22, 2020
9267b4f
Remove unused crate imports in 2018 edition crates
nn1ks Jun 23, 2020
7930f9a
Change heuristic for determining range literal
ayazhafiz Jun 23, 2020
bb882d7
Add test for issue-44861
JohnTitor Jun 23, 2020
43ef554
Add test for issue-51506
JohnTitor Jun 23, 2020
e817cd2
Add test for issue-59435
JohnTitor Jun 23, 2020
814782b
Add test for issue-69840
JohnTitor Jun 23, 2020
404df1c
Add re-exports to use suggestions
da-x Jun 21, 2020
86f6c0e
Record span of `const` kw in GenericParamKind
ayazhafiz Jun 21, 2020
f37c157
Update map.rs
nrabulinski Jun 23, 2020
037e930
Review fixes
da-x Jun 23, 2020
e02dafc
Update books
ehuss Jun 24, 2020
6c76cca
Rollup merge of #73507 - mati865:cleanup-mingw-llvm-linkage, r=matthe…
Manishearth Jun 24, 2020
dba2ae4
Rollup merge of #73588 - Amanieu:thumb-fp, r=nagisa
Manishearth Jun 24, 2020
1911553
Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morse
Manishearth Jun 24, 2020
f83ee17
Rollup merge of #73616 - pickfire:liballoc-hash, r=joshtriplett
Manishearth Jun 24, 2020
1f3b2ac
Rollup merge of #73619 - poliorcetics:mod-keyword, r=steveklabnik
Manishearth Jun 24, 2020
9284a64
Rollup merge of #73634 - nbdd0121:typeck, r=nikomatsakis
Manishearth Jun 24, 2020
19f7c10
Rollup merge of #73638 - yuqio:remove-unused-crate-imports, r=nikomat…
Manishearth Jun 24, 2020
8a9e87b
Rollup merge of #73639 - ayazhafiz:i/73553, r=davidtwco
Manishearth Jun 24, 2020
b71464c
Rollup merge of #73646 - JohnTitor:add-tests, r=Dylan-DPC
Manishearth Jun 24, 2020
0a17ac2
Rollup merge of #73652 - da-x:add-reexported-to-use-suggestions, r=pe…
Manishearth Jun 24, 2020
a3a803e
Rollup merge of #73667 - nrabulinski:master, r=Dylan-DPC
Manishearth Jun 24, 2020
ac13194
Rollup merge of #73675 - ehuss:update-books, r=ehuss
Manishearth Jun 24, 2020
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
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
8 changes: 6 additions & 2 deletions src/doc/unstable-book/src/library-features/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ Here is the list of currently supported register classes:
| AArch64 | `reg` | `x[0-28]`, `x30` | `r` |
| AArch64 | `vreg` | `v[0-31]` | `w` |
| AArch64 | `vreg_low16` | `v[0-15]` | `x` |
| ARM | `reg` | `r[0-r10]`, `r12`, `r14` | `r` |
| ARM | `reg` | `r[0-5]` `r7`\*, `r[8-10]`, `r11`\*, `r12`, `r14` | `r` |
| ARM (Thumb) | `reg_thumb` | `r[0-r7]` | `l` |
| ARM (ARM) | `reg_thumb` | `r[0-r10]`, `r12`, `r14` | `l` |
| ARM | `sreg` | `s[0-31]` | `t` |
Expand All @@ -497,6 +497,8 @@ Here is the list of currently supported register classes:
> Note #2: On x86-64 the high byte registers (e.g. `ah`) are only available when used as an explicit register. Specifying the `reg_byte` register class for an operand will always allocate a low byte register.
>
> Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported.
>
> Note #4: On ARM the frame pointer is either `r7` or `r11` depending on the platform.

Additional register classes may be added in the future based on demand (e.g. MMX, x87, etc).

Expand Down Expand Up @@ -591,7 +593,9 @@ Some registers cannot be used for input or output operands:
| Architecture | Unsupported register | Reason |
| ------------ | -------------------- | ------ |
| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |
| All | `bp` (x86), `r11` (ARM), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon) | The frame pointer cannot be used as an input or output. |
| All | `bp` (x86), `x29` (AArch64), `x8` (RISC-V), `fr` (Hexagon) | The frame pointer cannot be used as an input or output. |
| ARM | `r7` or `r11` | On ARM the frame pointer can be either `r7` or `r11` depending on the target. The frame pointer cannot be used as an input or output. |
| ARM | `r6` | `r6` is used internally by LLVM as a base pointer and therefore cannot be used as an input or output. |
| x86 | `k0` | This is a constant zero register which can't be modified. |
| x86 | `ip` | This is the program counter, not a real register. |
| x86 | `mm[0-7]` | MMX registers are not currently supported (but may be in the future). |
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ struct MergeIter<K, V, I: Iterator<Item = (K, V)>> {
}

impl<K: Ord, V> BTreeMap<K, V> {
/// Makes a new empty BTreeMap with a reasonable choice for B.
/// Makes a new empty BTreeMap.
///
/// Does not allocate anything on its own.
///
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use super::*;

use test;

#[bench]
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
fn bench_push_back_100(b: &mut test::Bencher) {
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
use core::array::LengthAtMost32;
use core::cmp::{self, Ordering};
use core::fmt;
use core::hash::{self, Hash};
use core::hash::{Hash, Hasher};
use core::intrinsics::{arith_offset, assume};
use core::iter::{FromIterator, FusedIterator, TrustedLen};
use core::marker::PhantomData;
Expand Down Expand Up @@ -1943,7 +1943,7 @@ impl<T: Clone> Clone for Vec<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Hash> Hash for Vec<T> {
#[inline]
fn hash<H: hash::Hasher>(&self, state: &mut H) {
fn hash<H: Hasher>(&self, state: &mut H) {
Hash::hash(&**self, state)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_ast/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ pub enum GenericParamKind {
},
Const {
ty: P<Ty>,
/// Span of the `const` keyword.
kw_span: Span,
},
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ pub fn noop_flat_map_generic_param<T: MutVisitor>(
GenericParamKind::Type { default } => {
visit_opt(default, |default| vis.visit_ty(default));
}
GenericParamKind::Const { ty } => {
GenericParamKind::Const { ty, kw_span: _ } => {
vis.visit_ty(ty);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
asm::InlineAsmReg::parse(
sess.asm_arch?,
|feature| sess.target_features.contains(&Symbol::intern(feature)),
&sess.target.target,
s,
)
.map_err(|e| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

(hir::ParamName::Plain(param.ident), kind)
}
GenericParamKind::Const { ref ty } => {
GenericParamKind::Const { ref ty, kw_span: _ } => {
let ty = self
.with_anonymous_lifetime_mode(AnonymousLifetimeMode::ReportError, |this| {
this.lower_ty(&ty, ImplTraitContext::disallowed())
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_ast_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,9 +1135,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
generics.params.iter().map(|param| {
let ident = Some(param.ident.to_string());
let (kind, ident) = match &param.kind {
GenericParamKind::Lifetime { .. } => (ParamKindOrd::Lifetime, ident),
GenericParamKind::Type { .. } => (ParamKindOrd::Type, ident),
GenericParamKind::Const { ref ty } => {
GenericParamKind::Lifetime => (ParamKindOrd::Lifetime, ident),
GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident),
GenericParamKind::Const { ref ty, kw_span: _ } => {
let ty = pprust::ty_to_string(ty);
(ParamKindOrd::Const, Some(format!("const {}: {}", param.ident, ty)))
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_pretty/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2578,7 +2578,7 @@ impl<'a> State<'a> {
s.print_type(default)
}
}
ast::GenericParamKind::Const { ref ty } => {
ast::GenericParamKind::Const { ref ty, kw_span: _ } => {
s.word_space("const");
s.print_ident(param.ident);
s.s.space();
Expand Down
1 change: 0 additions & 1 deletion src/librustc_ast_pretty/pprust/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::*;

use rustc_ast::ast;
use rustc_ast::with_default_globals;
use rustc_span;
use rustc_span::source_map::respan;
use rustc_span::symbol::Ident;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn inject_impl_of_structural_trait(
*default = None;
ast::GenericArg::Type(cx.ty_ident(span, param.ident))
}
ast::GenericParamKind::Const { ty: _ } => {
ast::GenericParamKind::Const { ty: _, kw_span: _ } => {
ast::GenericArg::Const(cx.const_ident(span, param.ident))
}
})
Expand Down
4 changes: 4 additions & 0 deletions src/librustc_codegen_llvm/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ const ARM_WHITELIST: &[(&str, Option<Symbol>)] = &[
("vfp2", Some(sym::arm_target_feature)),
("vfp3", Some(sym::arm_target_feature)),
("vfp4", Some(sym::arm_target_feature)),
// This is needed for inline assembly, but shouldn't be stabilized as-is
// since it should be enabled per-function using #[instruction_set], not
// #[target_feature].
("thumb-mode", Some(sym::arm_target_feature)),
];

const AARCH64_WHITELIST: &[(&str, Option<Symbol>)] = &[
Expand Down
1 change: 0 additions & 1 deletion src/librustc_data_structures/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ cfg_if! {
use parking_lot::Mutex as InnerLock;
use parking_lot::RwLock as InnerRwLock;

use std;
use std::thread;
pub use rayon::{join, scope};

Expand Down
8 changes: 1 addition & 7 deletions src/librustc_hir/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,13 +1511,7 @@ pub fn is_range_literal(sm: &SourceMap, expr: &Expr<'_>) -> bool {
// Check whether a span corresponding to a range expression is a
// range literal, rather than an explicit struct or `new()` call.
fn is_lit(sm: &SourceMap, span: &Span) -> bool {
let end_point = sm.end_point(*span);

if let Ok(end_string) = sm.span_to_snippet(end_point) {
!(end_string.ends_with('}') || end_string.ends_with(')'))
} else {
false
}
sm.span_to_snippet(*span).map(|range_src| range_src.contains("..")).unwrap_or(false)
};

match expr.kind {
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,9 @@ fn main() {
}
}

// LLVM requires symbols from this library, but apparently they're not printed
// during llvm-config?
// Libstdc++ depends on pthread which Rust doesn't link on MinGW
// since nothing else requires it.
if target.contains("windows-gnu") {
println!("cargo:rustc-link-lib=static-nobundle=gcc_s");
println!("cargo:rustc-link-lib=static-nobundle=pthread");
println!("cargo:rustc-link-lib=dylib=uuid");
}
}
6 changes: 3 additions & 3 deletions src/librustc_parse/parser/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ impl<'a> Parser<'a> {
}

fn parse_const_param(&mut self, preceding_attrs: Vec<Attribute>) -> PResult<'a, GenericParam> {
let lo = self.token.span;
let const_span = self.token.span;

self.expect_keyword(kw::Const)?;
let ident = self.parse_ident()?;
self.expect(&token::Colon)?;
let ty = self.parse_ty()?;

self.sess.gated_spans.gate(sym::const_generics, lo.to(self.prev_token.span));
self.sess.gated_spans.gate(sym::const_generics, const_span.to(self.prev_token.span));

Ok(GenericParam {
ident,
id: ast::DUMMY_NODE_ID,
attrs: preceding_attrs.into(),
bounds: Vec::new(),
kind: GenericParamKind::Const { ty },
kind: GenericParamKind::Const { ty, kw_span: const_span },
is_placeholder: false,
})
}
Expand Down
28 changes: 20 additions & 8 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,18 +643,18 @@ impl<'a> Resolver<'a> {
let not_local_module = crate_name.name != kw::Crate;
let mut worklist =
vec![(start_module, Vec::<ast::PathSegment>::new(), true, not_local_module)];
let mut worklist_via_import = vec![];

while let Some((in_module, path_segments, accessible, in_module_is_extern)) = worklist.pop()
while let Some((in_module, path_segments, accessible, in_module_is_extern)) =
match worklist.pop() {
None => worklist_via_import.pop(),
Some(x) => Some(x),
}
{
// We have to visit module children in deterministic order to avoid
// instabilities in reported imports (#43552).
in_module.for_each_child(self, |this, ident, ns, name_binding| {
// avoid imports entirely
if name_binding.is_import() && !name_binding.is_extern_crate() {
return;
}

// avoid non-importable candidates as well
// avoid non-importable candidates
if !name_binding.is_importable() {
return;
}
Expand All @@ -667,6 +667,17 @@ impl<'a> Resolver<'a> {
return;
}

let via_import = name_binding.is_import() && !name_binding.is_extern_crate();

// There is an assumption elsewhere that paths of variants are in the enum's
// declaration and not imported. With this assumption, the variant component is
// chopped and the rest of the path is assumed to be the enum's own path. For
// errors where a variant is used as the type instead of the enum, this causes
// funny looking invalid suggestions, i.e `foo` instead of `foo::MyEnum`.
if via_import && name_binding.is_possibly_imported_variant() {
return;
}

// collect results based on the filter function
// avoid suggesting anything from the same module in which we are resolving
if ident.name == lookup_ident.name
Expand Down Expand Up @@ -724,7 +735,8 @@ impl<'a> Resolver<'a> {
let is_extern = in_module_is_extern || name_binding.is_extern_crate();
// add the module to the lookup
if seen_modules.insert(module.def_id().unwrap()) {
worklist.push((module, path_segments, child_accessible, is_extern));
if via_import { &mut worklist_via_import } else { &mut worklist }
.push((module, path_segments, child_accessible, is_extern));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {

for param in &generics.params {
match param.kind {
GenericParamKind::Lifetime { .. } => self.visit_generic_param(param),
GenericParamKind::Type { ref default, .. } => {
GenericParamKind::Lifetime => self.visit_generic_param(param),
GenericParamKind::Type { ref default } => {
for bound in &param.bounds {
self.visit_param_bound(bound);
}
Expand All @@ -551,7 +551,7 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
// Allow all following defaults to refer to this type parameter.
default_ban_rib.bindings.remove(&Ident::with_dummy_span(param.ident.name));
}
GenericParamKind::Const { ref ty } => {
GenericParamKind::Const { ref ty, kw_span: _ } => {
for bound in &param.bounds {
self.visit_param_bound(bound);
}
Expand Down
7 changes: 7 additions & 0 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,13 @@ impl<'a> NameBinding<'a> {
}
}

fn is_possibly_imported_variant(&self) -> bool {
match self.kind {
NameBindingKind::Import { binding, .. } => binding.is_possibly_imported_variant(),
_ => self.is_variant(),
}
}

// We sometimes need to treat variants as `pub` for backwards compatibility.
fn pseudo_vis(&self) -> ty::Visibility {
if self.is_variant() && self.res().def_id().is_local() {
Expand Down
40 changes: 36 additions & 4 deletions src/librustc_target/asm/arm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{InlineAsmArch, InlineAsmType};
use crate::spec::Target;
use rustc_macros::HashStable_Generic;
use std::fmt;

Expand Down Expand Up @@ -58,6 +59,37 @@ impl ArmInlineAsmRegClass {
}
}

// This uses the same logic as useR7AsFramePointer in LLVM
fn frame_pointer_is_r7(mut has_feature: impl FnMut(&str) -> bool, target: &Target) -> bool {
target.options.is_like_osx || (!target.options.is_like_windows && has_feature("thumb-mode"))
}

fn frame_pointer_r11(
_arch: InlineAsmArch,
has_feature: impl FnMut(&str) -> bool,
target: &Target,
_allocating: bool,
) -> Result<(), &'static str> {
if !frame_pointer_is_r7(has_feature, target) {
Err("the frame pointer (r11) cannot be used as an operand for inline asm")
} else {
Ok(())
}
}

fn frame_pointer_r7(
_arch: InlineAsmArch,
has_feature: impl FnMut(&str) -> bool,
target: &Target,
_allocating: bool,
) -> Result<(), &'static str> {
if frame_pointer_is_r7(has_feature, target) {
Err("the frame pointer (r7) cannot be used as an operand for inline asm")
} else {
Ok(())
}
}

def_regs! {
Arm ArmInlineAsmReg ArmInlineAsmRegClass {
r0: reg, reg_thumb = ["r0", "a1"],
Expand All @@ -66,11 +98,11 @@ def_regs! {
r3: reg, reg_thumb = ["r3", "a4"],
r4: reg, reg_thumb = ["r4", "v1"],
r5: reg, reg_thumb = ["r5", "v2"],
r6: reg, reg_thumb = ["r6", "v3"],
r7: reg, reg_thumb = ["r7", "v4"],
r7: reg, reg_thumb = ["r7", "v4"] % frame_pointer_r7,
r8: reg = ["r8", "v5"],
r9: reg = ["r9", "v6", "rfp"],
r10: reg = ["r10", "sl"],
r11: reg = ["r11", "fp"] % frame_pointer_r11,
r12: reg = ["r12", "ip"],
r14: reg = ["r14", "lr"],
s0: sreg, sreg_low16 = ["s0"],
Expand Down Expand Up @@ -153,8 +185,8 @@ def_regs! {
q13: qreg = ["q13"],
q14: qreg = ["q14"],
q15: qreg = ["q15"],
#error = ["r11", "fp"] =>
"the frame pointer cannot be used as an operand for inline asm",
#error = ["r6", "v3"] =>
"r6 is used internally by LLVM and cannot be used as an operand for inline asm",
#error = ["r13", "sp"] =>
"the stack pointer cannot be used as an operand for inline asm",
#error = ["r15", "pc"] =>
Expand Down
Loading