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 11 pull requests #79215

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6554086
Add u128 and i128 integer tests
CDirkx Nov 14, 2020
69477f5
Clarify availability of atomic operations
Nov 17, 2020
b491587
Extract write_srclink to its own method
aDotInTheVoid Nov 18, 2020
1094f97
Test drop order for (destructuring) assignments
fanzier Nov 18, 2020
ae644a2
add [src] links to methods on a trait's page
aDotInTheVoid Nov 18, 2020
c711833
Qualify `panic!` as `core::panic!` in non-built-in `core` macros
camelid Oct 25, 2020
50b34c4
Clean up `core` macros documentation
camelid Oct 25, 2020
c48ed78
Add two more test cases
camelid Oct 29, 2020
a050c55
Remove unused `use std::panic;`s
camelid Oct 30, 2020
566e877
Make compiletest testing use the local sysroot
cuviper Nov 18, 2020
8afa22d
Never inline naked functions
tmiasko Nov 19, 2020
8247223
Revert "Always use param_env_reveal_all_normalized in validator"
tmiasko Nov 19, 2020
0ab4458
Revert "Normalize function type during validation"
tmiasko Nov 19, 2020
de08df2
Make as{_mut,}_slice on array::IntoIter public
est31 Nov 19, 2020
0510fd3
Update 32 bit mir-opt test output.
m-ou-se Nov 19, 2020
54588c8
Add jyn514 email alias to mailmap
pickfire Nov 19, 2020
b49fbc9
expand: Tell built-in macros whether we are currently in forced expan…
petrochenkov Nov 14, 2020
e7ee4d6
expand: Move `fully_configure` to `config.rs`
petrochenkov Nov 18, 2020
69894ce
resolve: Introduce a separate `NonMacroAttrKind` for legacy derive he…
petrochenkov Nov 18, 2020
68f94e9
resolve: Centralize some error reporting for unexpected macro resolut…
petrochenkov Nov 18, 2020
dfb690e
resolve/expand: Misc cleanup
petrochenkov Nov 18, 2020
ec54720
expand: Cleanup attribute collection in invocation collector
petrochenkov Nov 18, 2020
cd2177f
expand: Stop derive expansion un unexpected targets early
petrochenkov Nov 18, 2020
d575aa4
expand: Mark some dead code in derive expansion as unreachable
petrochenkov Nov 18, 2020
82f694b
Rollup merge of #78343 - camelid:macros-qualify-panic, r=m-ou-se
Dylan-DPC Nov 19, 2020
ea3f1af
Rollup merge of #79119 - jamesmunns:patch-1, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
450f54e
Rollup merge of #79123 - CDirkx:128-bits, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
f916a71
Rollup merge of #79177 - fanzier:drop-order-test, r=RalfJung
Dylan-DPC Nov 19, 2020
d34c279
Rollup merge of #79181 - aDotInTheVoid:provided-method-source-link, r…
Dylan-DPC Nov 19, 2020
c520e83
Rollup merge of #79183 - cuviper:compiletest-test-sysroot, r=Mark-Sim…
Dylan-DPC Nov 19, 2020
a234e55
Rollup merge of #79185 - petrochenkov:derattr2, r=Aaron1011
Dylan-DPC Nov 19, 2020
09b3a8b
Rollup merge of #79192 - tmiasko:naked-noinline, r=oli-obk
Dylan-DPC Nov 19, 2020
08184c3
Rollup merge of #79193 - tmiasko:revert-78969-normalize, r=davidtwco
Dylan-DPC Nov 19, 2020
1a2266f
Rollup merge of #79194 - est31:array_into_iter_slice, r=scottmcm
Dylan-DPC Nov 19, 2020
26f0226
Rollup merge of #79204 - pickfire:patch-3, r=jyn514
Dylan-DPC Nov 19, 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
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Jorge Aparicio <[email protected]> <[email protected]>
Joseph Martin <[email protected]>
Joseph T. Lyons <[email protected]> <[email protected]>
Joseph T. Lyons <[email protected]> <[email protected]>
Joshua Nelson <[email protected]> <[email protected]>
jumbatm <[email protected]> <[email protected]>
Junyoung Cho <[email protected]>
Jyun-Yan You <[email protected]> <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
}
}

#[derive(Clone, PartialEq, Encodable, Decodable)]
#[derive(Copy, Clone, PartialEq, Encodable, Decodable)]
pub enum InlineAttr {
None,
Hint,
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_builtin_macros/src/cfg_accessible.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Implementation of the `#[cfg_accessible(path)]` attribute macro.

use rustc_ast as ast;
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier};
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier};
use rustc_feature::AttributeTemplate;
use rustc_parse::validate_attr;
use rustc_span::symbol::sym;
Expand Down Expand Up @@ -31,7 +31,7 @@ impl MultiItemModifier for Expander {
fn expand(
&self,
ecx: &mut ExtCtxt<'_>,
_span: Span,
span: Span,
meta_item: &ast::MetaItem,
item: Annotatable,
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
Expand All @@ -49,11 +49,14 @@ impl MultiItemModifier for Expander {
None => return ExpandResult::Ready(Vec::new()),
};

let failure_msg = "cannot determine whether the path is accessible or not";
match ecx.resolver.cfg_accessible(ecx.current_expansion.id, path) {
Ok(true) => ExpandResult::Ready(vec![item]),
Ok(false) => ExpandResult::Ready(Vec::new()),
Err(_) => ExpandResult::Retry(item, failure_msg.into()),
Err(Indeterminate) if ecx.force_mode => {
ecx.span_err(span, "cannot determine whether the path is accessible or not");
ExpandResult::Ready(vec![item])
}
Err(Indeterminate) => ExpandResult::Retry(item),
}
}
}
15 changes: 2 additions & 13 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,7 @@ impl<'a> TraitDef<'a> {
_ => false,
})
}
_ => {
// Non-ADT derive is an error, but it should have been
// set earlier; see
// librustc_expand/expand.rs:MacroExpander::fully_expand_fragment()
// librustc_expand/base.rs:Annotatable::derive_allowed()
return;
}
_ => unreachable!(),
};
let container_id = cx.current_expansion.id.expn_data().parent;
let always_copy = has_no_type_params && cx.resolver.has_derive_copy(container_id);
Expand Down Expand Up @@ -475,12 +469,7 @@ impl<'a> TraitDef<'a> {
);
push(Annotatable::Item(P(ast::Item { attrs, ..(*newitem).clone() })))
}
_ => {
// Non-Item derive is an error, but it should have been
// set earlier; see
// librustc_expand/expand.rs:MacroExpander::fully_expand_fragment()
// librustc_expand/base.rs:Annotatable::derive_allowed()
}
_ => unreachable!(),
}
}

Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_builtin_macros/src/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,7 @@ fn inject_impl_of_structural_trait(
) {
let item = match *item {
Annotatable::Item(ref item) => item,
_ => {
// Non-Item derive is an error, but it should have been
// set earlier; see
// librustc_expand/expand.rs:MacroExpander::fully_expand_fragment()
// librustc_expand/base.rs:Annotatable::derive_allowed()
return;
}
_ => unreachable!(),
};

let generics = match item.kind {
Expand Down
12 changes: 9 additions & 3 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::value::Value;

/// Mark LLVM function to use provided inline heuristic.
#[inline]
fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr, requires_inline: bool) {
fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr) {
use self::InlineAttr::*;
match inline {
Hint => Attribute::InlineHint.apply_llfn(Function, val),
Expand All @@ -35,7 +35,6 @@ fn inline(cx: &CodegenCx<'ll, '_>, val: &'ll Value, inline: InlineAttr, requires
Attribute::NoInline.apply_llfn(Function, val);
}
}
None if requires_inline => Attribute::InlineHint.apply_llfn(Function, val),
None => {}
};
}
Expand Down Expand Up @@ -226,7 +225,14 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
}
}

inline(cx, llfn, codegen_fn_attrs.inline.clone(), instance.def.requires_inline(cx.tcx));
let inline_attr = if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
InlineAttr::Never
} else if codegen_fn_attrs.inline == InlineAttr::None && instance.def.requires_inline(cx.tcx) {
InlineAttr::Hint
} else {
codegen_fn_attrs.inline
};
inline(cx, llfn, inline_attr);

// The `uwtable` attribute according to LLVM is:
//
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ pub enum ExpandResult<T, U> {
/// Expansion produced a result (possibly dummy).
Ready(T),
/// Expansion could not produce a result and needs to be retried.
/// The string is an explanation that will be printed if we are stuck in an infinite retry loop.
Retry(U, String),
Retry(U),
}

// `meta_item` is the attribute, and `item` is the item being modified.
Expand Down Expand Up @@ -889,8 +888,10 @@ pub trait ResolverExpand {
/// Some parent node that is close enough to the given macro call.
fn lint_node_id(&mut self, expn_id: ExpnId) -> NodeId;

// Resolver interfaces for specific built-in macros.
/// Does `#[derive(...)]` attribute with the given `ExpnId` have built-in `Copy` inside it?
fn has_derive_copy(&self, expn_id: ExpnId) -> bool;
fn add_derive_copy(&mut self, expn_id: ExpnId);
/// Path resolution logic for `#[cfg_accessible(path)]`.
fn cfg_accessible(&mut self, expn_id: ExpnId, path: &ast::Path) -> Result<bool, Indeterminate>;
}

Expand Down Expand Up @@ -919,6 +920,9 @@ pub struct ExtCtxt<'a> {
pub root_path: PathBuf,
pub resolver: &'a mut dyn ResolverExpand,
pub current_expansion: ExpansionData,
/// Error recovery mode entered when expansion is stuck
/// (or during eager expansion, but that's a hack).
pub force_mode: bool,
pub expansions: FxHashMap<Span, Vec<String>>,
/// Called directly after having parsed an external `mod foo;` in expansion.
pub(super) extern_mod_loaded: Option<&'a dyn Fn(&ast::Crate)>,
Expand All @@ -945,6 +949,7 @@ impl<'a> ExtCtxt<'a> {
directory_ownership: DirectoryOwnership::Owned { relative: None },
prior_type_ascription: None,
},
force_mode: false,
expansions: FxHashMap::default(),
}
}
Expand Down
45 changes: 45 additions & 0 deletions compiler/rustc_expand/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Conditional compilation stripping.

use crate::base::Annotatable;

use rustc_ast::attr::HasAttrs;
use rustc_ast::mut_visit::*;
use rustc_ast::ptr::P;
Expand Down Expand Up @@ -496,6 +498,49 @@ impl<'a> StripUnconfigured<'a> {
pub fn configure_fn_decl(&mut self, fn_decl: &mut ast::FnDecl) {
fn_decl.inputs.flat_map_in_place(|arg| self.configure(arg));
}

pub fn fully_configure(&mut self, item: Annotatable) -> Annotatable {
// Since the item itself has already been configured by the InvocationCollector,
// we know that fold result vector will contain exactly one element
match item {
Annotatable::Item(item) => Annotatable::Item(self.flat_map_item(item).pop().unwrap()),
Annotatable::TraitItem(item) => {
Annotatable::TraitItem(self.flat_map_trait_item(item).pop().unwrap())
}
Annotatable::ImplItem(item) => {
Annotatable::ImplItem(self.flat_map_impl_item(item).pop().unwrap())
}
Annotatable::ForeignItem(item) => {
Annotatable::ForeignItem(self.flat_map_foreign_item(item).pop().unwrap())
}
Annotatable::Stmt(stmt) => {
Annotatable::Stmt(stmt.map(|stmt| self.flat_map_stmt(stmt).pop().unwrap()))
}
Annotatable::Expr(mut expr) => Annotatable::Expr({
self.visit_expr(&mut expr);
expr
}),
Annotatable::Arm(arm) => Annotatable::Arm(self.flat_map_arm(arm).pop().unwrap()),
Annotatable::Field(field) => {
Annotatable::Field(self.flat_map_field(field).pop().unwrap())
}
Annotatable::FieldPat(fp) => {
Annotatable::FieldPat(self.flat_map_field_pattern(fp).pop().unwrap())
}
Annotatable::GenericParam(param) => {
Annotatable::GenericParam(self.flat_map_generic_param(param).pop().unwrap())
}
Annotatable::Param(param) => {
Annotatable::Param(self.flat_map_param(param).pop().unwrap())
}
Annotatable::StructField(sf) => {
Annotatable::StructField(self.flat_map_struct_field(sf).pop().unwrap())
}
Annotatable::Variant(v) => {
Annotatable::Variant(self.flat_map_variant(v).pop().unwrap())
}
}
}
}

impl<'a> MutVisitor for StripUnconfigured<'a> {
Expand Down
Loading