Skip to content

Rollup of 11 pull requests #79220

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

Merged
merged 31 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 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
566e877
Make compiletest testing use the local sysroot
cuviper Nov 18, 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
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
53f969d
Add the "memcpy" doc alias to slice::copy_from_slice
yoshuawuyts Nov 19, 2020
f59d030
Move `rustc_ty` -> `rustc_ty_utils`
LeSeulArtichaut Nov 19, 2020
138e96d
Rollup merge of #79119 - jamesmunns:patch-1, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
c2a277c
Rollup merge of #79123 - CDirkx:128-bits, r=Mark-Simulacrum
Dylan-DPC Nov 19, 2020
acc2e23
Rollup merge of #79177 - fanzier:drop-order-test, r=RalfJung
Dylan-DPC Nov 19, 2020
192ed76
Rollup merge of #79181 - aDotInTheVoid:provided-method-source-link, r…
Dylan-DPC Nov 19, 2020
d5ee4ed
Rollup merge of #79183 - cuviper:compiletest-test-sysroot, r=Mark-Sim…
Dylan-DPC Nov 19, 2020
8216b35
Rollup merge of #79185 - petrochenkov:derattr2, r=Aaron1011
Dylan-DPC Nov 19, 2020
084fc29
Rollup merge of #79193 - tmiasko:revert-78969-normalize, r=davidtwco
Dylan-DPC Nov 19, 2020
169e221
Rollup merge of #79194 - est31:array_into_iter_slice, r=scottmcm
Dylan-DPC Nov 19, 2020
39495cb
Rollup merge of #79204 - pickfire:patch-3, r=jyn514
Dylan-DPC Nov 19, 2020
95da425
Rollup merge of #79212 - LeSeulArtichaut:rustc-ty, r=jonas-schievink
Dylan-DPC Nov 19, 2020
5adc00f
Rollup merge of #79217 - yoshuawuyts:copy_from_slice-alias, r=Mark-Si…
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,7 @@ dependencies = [
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
"rustc_ty",
"rustc_ty_utils",
"rustc_typeck",
"smallvec 1.4.2",
"tempfile",
Expand Down Expand Up @@ -4240,7 +4240,7 @@ dependencies = [
]

[[package]]
name = "rustc_ty"
name = "rustc_ty_utils"
version = "0.0.0"
dependencies = [
"rustc_data_structures",
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
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