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 3 pull requests #63611

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0b713ae
typeck: extract ban_private_field_access
Centril Aug 13, 2019
5e019de
typeck: extract ban_take_value_of_method
Centril Aug 13, 2019
9805846
typeck: extract maybe_suggest_array_indexing
Centril Aug 13, 2019
039c789
typeck: extract suggest_first_deref_field
Centril Aug 13, 2019
01e96dc
typeck: extract suggest_fields_on_recordish
Centril Aug 13, 2019
0741441
typeck: restructure check_field a bit
Centril Aug 13, 2019
88398a4
typeck: on wrong <expr>.await suggest -> 2018
Centril Aug 13, 2019
9287eb6
typeck: add tests for suggesting -> 2018 on wrong <expr>.await
Centril Aug 13, 2019
f54503c
libcore: more cleanups using associated_type_bounds
Centril Aug 15, 2019
dfcbe75
syntax_pos: Introduce a helper for checking whether a span comes from…
petrochenkov Aug 10, 2019
67d6ce4
syntax_pos: `NO_EXPANSION`/`SyntaxContext::empty()` -> `SyntaxContext…
petrochenkov Aug 10, 2019
6cb28b6
`Ident::with_empty_ctxt` -> `Ident::with_dummy_span`
petrochenkov Aug 10, 2019
73dee25
hygiene: Remove `Option`s from functions returning `ExpnInfo`
petrochenkov Aug 11, 2019
23b82c3
resolve: Move macro resolution traces from `Module`s to `Resolver`
petrochenkov Aug 12, 2019
cfbb60b
resolve: Do not "normalize away" trait/enum modules prematurely
petrochenkov Aug 12, 2019
1a1557c
resolve: Add `ParentScope::default`, eliminate `dummy_parent_scope`
petrochenkov Aug 12, 2019
59dd07a
resolve: Eliminate `InvocationData`
petrochenkov Aug 12, 2019
ea68bc8
resolve: Make `ParentScope` `Copy`
petrochenkov Aug 12, 2019
310ee4d
resolve: Privatize `BuildReducedGraphVisitor`
petrochenkov Aug 12, 2019
aca1353
resolve: Add some comments to the main modules
petrochenkov Aug 12, 2019
1a44773
hygiene: Merge `ExpnInfo` and `InternalExpnData`
petrochenkov Aug 13, 2019
74190a5
syntax_pos: Remove the duplicate global edition
petrochenkov Aug 13, 2019
650f19a
hygiene: Merge a tiny bit of the "share expansion definition data" PR
petrochenkov Aug 13, 2019
136db22
hygiene: `ExpnInfo` -> `ExpnData`
petrochenkov Aug 13, 2019
c762773
resolve: `ParentScope::default` -> `ParentScope::module`
petrochenkov Aug 15, 2019
87fb57c
Rollup merge of #63535 - petrochenkov:expndata, r=matthewjasper
Centril Aug 15, 2019
9f56dd0
Rollup merge of #63539 - Centril:2015.await, r=oli-obk
Centril Aug 15, 2019
6727afd
Rollup merge of #63584 - Centril:cleanup-core-with-more-atb, r=alexreg
Centril Aug 15, 2019
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
8 changes: 2 additions & 6 deletions src/libcore/iter/adapters/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ impl<I: Iterator, U: IntoIterator, F> Iterator for FlatMap<I, U, F>
impl<I: DoubleEndedIterator, U, F> DoubleEndedIterator for FlatMap<I, U, F>
where
F: FnMut(I::Item) -> U,
U: IntoIterator,
U::IntoIter: DoubleEndedIterator,
U: IntoIterator<IntoIter: DoubleEndedIterator>,
{
#[inline]
fn next_back(&mut self) -> Option<U::Item> { self.inner.next_back() }
Expand Down Expand Up @@ -107,10 +106,7 @@ impl<I, U, F> FusedIterator for FlatMap<I, U, F>
/// [`Iterator`]: trait.Iterator.html
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "iterator_flatten", since = "1.29.0")]
pub struct Flatten<I: Iterator>
where
I::Item: IntoIterator,
{
pub struct Flatten<I: Iterator<Item: IntoIterator>> {
inner: FlattenCompat<I, <I::Item as IntoIterator>::IntoIter>,
}

Expand Down
15 changes: 7 additions & 8 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use syntax::errors;
use syntax::ext::base::SpecialDerives;
use syntax::ext::hygiene::ExpnId;
use syntax::print::pprust;
use syntax::source_map::{respan, ExpnInfo, ExpnKind, DesugaringKind, Spanned};
use syntax::source_map::{respan, ExpnData, ExpnKind, DesugaringKind, Spanned};
use syntax::symbol::{kw, sym, Symbol};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::parse::token::{self, Token};
Expand Down Expand Up @@ -704,10 +704,9 @@ impl<'a> LoweringContext<'a> {
span: Span,
allow_internal_unstable: Option<Lrc<[Symbol]>>,
) -> Span {
span.fresh_expansion(ExpnId::root(), ExpnInfo {
def_site: span,
span.fresh_expansion(ExpnData {
allow_internal_unstable,
..ExpnInfo::default(ExpnKind::Desugaring(reason), span, self.sess.edition())
..ExpnData::default(ExpnKind::Desugaring(reason), span, self.sess.edition())
})
}

Expand Down Expand Up @@ -1224,7 +1223,7 @@ impl<'a> LoweringContext<'a> {
P(hir::Path {
res,
segments: hir_vec![hir::PathSegment::from_ident(
Ident::with_empty_ctxt(kw::SelfUpper)
Ident::with_dummy_span(kw::SelfUpper)
)],
span: t.span,
}),
Expand Down Expand Up @@ -1558,7 +1557,7 @@ impl<'a> LoweringContext<'a> {

let (name, kind) = match name {
hir::LifetimeName::Underscore => (
hir::ParamName::Plain(Ident::with_empty_ctxt(kw::UnderscoreLifetime)),
hir::ParamName::Plain(Ident::with_dummy_span(kw::UnderscoreLifetime)),
hir::LifetimeParamKind::Elided,
),
hir::LifetimeName::Param(param_name) => (
Expand Down Expand Up @@ -2002,7 +2001,7 @@ impl<'a> LoweringContext<'a> {
bindings: hir_vec![
hir::TypeBinding {
hir_id: this.next_id(),
ident: Ident::with_empty_ctxt(FN_OUTPUT_NAME),
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
kind: hir::TypeBindingKind::Equality {
ty: output
.as_ref()
Expand Down Expand Up @@ -2394,7 +2393,7 @@ impl<'a> LoweringContext<'a> {
let future_params = P(hir::GenericArgs {
args: hir_vec![],
bindings: hir_vec![hir::TypeBinding {
ident: Ident::with_empty_ctxt(FN_OUTPUT_NAME),
ident: Ident::with_dummy_span(FN_OUTPUT_NAME),
kind: hir::TypeBindingKind::Equality {
ty: output_ty,
},
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/hir/lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl LoweringContext<'_> {

// let mut pinned = <expr>;
let expr = P(self.lower_expr(expr));
let pinned_ident = Ident::with_empty_ctxt(sym::pinned);
let pinned_ident = Ident::with_dummy_span(sym::pinned);
let (pinned_pat, pinned_pat_hid) = self.pat_ident_binding_mode(
span,
pinned_ident,
Expand Down Expand Up @@ -593,7 +593,7 @@ impl LoweringContext<'_> {
let loop_node_id = self.sess.next_node_id();
let loop_hir_id = self.lower_node_id(loop_node_id);
let ready_arm = {
let x_ident = Ident::with_empty_ctxt(sym::result);
let x_ident = Ident::with_dummy_span(sym::result);
let (x_pat, x_pat_hid) = self.pat_ident(span, x_ident);
let x_expr = P(self.expr_ident(span, x_ident, x_pat_hid));
let ready_pat = self.pat_std_enum(
Expand Down Expand Up @@ -1070,9 +1070,9 @@ impl LoweringContext<'_> {
);
head.span = desugared_span;

let iter = Ident::with_empty_ctxt(sym::iter);
let iter = Ident::with_dummy_span(sym::iter);

let next_ident = Ident::with_empty_ctxt(sym::__next);
let next_ident = Ident::with_dummy_span(sym::__next);
let (next_pat, next_pat_hid) = self.pat_ident_binding_mode(
desugared_span,
next_ident,
Expand All @@ -1081,7 +1081,7 @@ impl LoweringContext<'_> {

// `::std::option::Option::Some(val) => __next = val`
let pat_arm = {
let val_ident = Ident::with_empty_ctxt(sym::val);
let val_ident = Ident::with_dummy_span(sym::val);
let (val_pat, val_pat_hid) = self.pat_ident(pat.span, val_ident);
let val_expr = P(self.expr_ident(pat.span, val_ident, val_pat_hid));
let next_expr = P(self.expr_ident(pat.span, next_ident, next_pat_hid));
Expand Down Expand Up @@ -1247,7 +1247,7 @@ impl LoweringContext<'_> {

// `Ok(val) => #[allow(unreachable_code)] val,`
let ok_arm = {
let val_ident = Ident::with_empty_ctxt(sym::val);
let val_ident = Ident::with_dummy_span(sym::val);
let (val_pat, val_pat_nid) = self.pat_ident(span, val_ident);
let val_expr = P(self.expr_ident_with_attrs(
span,
Expand All @@ -1263,7 +1263,7 @@ impl LoweringContext<'_> {
// `Err(err) => #[allow(unreachable_code)]
// return Try::from_error(From::from(err)),`
let err_arm = {
let err_ident = Ident::with_empty_ctxt(sym::err);
let err_ident = Ident::with_dummy_span(sym::err);
let (err_local, err_local_nid) = self.pat_ident(try_span, err_ident);
let from_expr = {
let from_path = &[sym::convert, sym::From, sym::from];
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl ParamName {
match *self {
ParamName::Plain(ident) => ident,
ParamName::Fresh(_) |
ParamName::Error => Ident::with_empty_ctxt(kw::UnderscoreLifetime),
ParamName::Error => Ident::with_dummy_span(kw::UnderscoreLifetime),
}
}

Expand Down Expand Up @@ -237,8 +237,8 @@ impl LifetimeName {
pub fn ident(&self) -> Ident {
match *self {
LifetimeName::Implicit | LifetimeName::Error => Ident::invalid(),
LifetimeName::Underscore => Ident::with_empty_ctxt(kw::UnderscoreLifetime),
LifetimeName::Static => Ident::with_empty_ctxt(kw::StaticLifetime),
LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime),
LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime),
LifetimeName::Param(param_name) => param_name.ident(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ impl<'a> State<'a> {
}

pub fn print_name(&mut self, name: ast::Name) {
self.print_ident(ast::Ident::with_empty_ctxt(name))
self.print_ident(ast::Ident::with_dummy_span(name))
}

pub fn print_for_decl(&mut self, loc: &hir::Local, coll: &hir::Expr) {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
let line_col_len = col | line | len;
std_hash::Hash::hash(&line_col_len, hasher);

if span.ctxt == SyntaxContext::empty() {
if span.ctxt == SyntaxContext::root() {
TAG_NO_EXPANSION.hash_stable(hcx, hasher);
} else {
TAG_EXPANSION.hash_stable(hcx, hasher);
Expand All @@ -370,7 +370,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for Span {
}

let mut hasher = StableHasher::new();
expn_id.expn_info().hash_stable(hcx, &mut hasher);
expn_id.expn_data().hash_stable(hcx, &mut hasher);
let sub_hash: Fingerprint = hasher.finish();
let sub_hash = sub_hash.to_smaller_hash();
cache.borrow_mut().insert(expn_id, sub_hash);
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,10 @@ impl_stable_hash_for!(enum ::syntax_pos::hygiene::Transparency {
Opaque,
});

impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnInfo {
call_site,
impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnData {
kind,
parent -> _,
call_site,
def_site,
default_transparency,
allow_internal_unstable,
Expand Down
35 changes: 12 additions & 23 deletions src/librustc/lint/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use errors::Applicability;
use rustc_data_structures::fx::FxHashMap;
use syntax::ast::{Ident, Item, ItemKind};
use syntax::symbol::{sym, Symbol};
use syntax_pos::ExpnInfo;

declare_tool_lint! {
pub rustc::DEFAULT_HASH_TYPES,
Expand Down Expand Up @@ -108,7 +107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind {
.help("try using `Ty` instead")
.emit();
} else {
if ty.span.ctxt().outer_expn_info().is_some() {
if ty.span.from_expansion() {
return;
}
if let Some(t) = is_ty_or_ty_ctxt(cx, ty) {
Expand Down Expand Up @@ -228,30 +227,20 @@ impl EarlyLintPass for LintPassImpl {
if let ItemKind::Impl(_, _, _, _, Some(lint_pass), _, _) = &item.node {
if let Some(last) = lint_pass.path.segments.last() {
if last.ident.name == sym::LintPass {
match &lint_pass.path.span.ctxt().outer_expn_info() {
Some(info) if is_lint_pass_expansion(info) => {}
_ => {
cx.struct_span_lint(
LINT_PASS_IMPL_WITHOUT_MACRO,
lint_pass.path.span,
"implementing `LintPass` by hand",
)
.help("try using `declare_lint_pass!` or `impl_lint_pass!` instead")
.emit();
}
let expn_data = lint_pass.path.span.ctxt().outer_expn_data();
let call_site = expn_data.call_site;
if expn_data.kind.descr() != sym::impl_lint_pass &&
call_site.ctxt().outer_expn_data().kind.descr() != sym::declare_lint_pass {
cx.struct_span_lint(
LINT_PASS_IMPL_WITHOUT_MACRO,
lint_pass.path.span,
"implementing `LintPass` by hand",
)
.help("try using `declare_lint_pass!` or `impl_lint_pass!` instead")
.emit();
}
}
}
}
}
}

fn is_lint_pass_expansion(expn_info: &ExpnInfo) -> bool {
if expn_info.kind.descr() == sym::impl_lint_pass {
true
} else if let Some(info) = expn_info.call_site.ctxt().outer_expn_info() {
info.kind.descr() == sym::declare_lint_pass
} else {
false
}
}
19 changes: 6 additions & 13 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,21 +885,16 @@ pub fn provide(providers: &mut Providers<'_>) {
/// This is used to test whether a lint should not even begin to figure out whether it should
/// be reported on the current node.
pub fn in_external_macro(sess: &Session, span: Span) -> bool {
let info = match span.ctxt().outer_expn_info() {
Some(info) => info,
// no ExpnInfo means this span doesn't come from a macro
None => return false,
};

match info.kind {
let expn_data = span.ctxt().outer_expn_data();
match expn_data.kind {
ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop) => false,
ExpnKind::Desugaring(_) => true, // well, it's "external"
ExpnKind::Macro(MacroKind::Bang, _) => {
if info.def_site.is_dummy() {
if expn_data.def_site.is_dummy() {
// dummy span for the def_site means it's an external macro
return true;
}
match sess.source_map().span_to_snippet(info.def_site) {
match sess.source_map().span_to_snippet(expn_data.def_site) {
Ok(code) => !code.starts_with("macro_rules"),
// no snippet = external macro or compiler-builtin expansion
Err(_) => true,
Expand All @@ -911,10 +906,8 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {

/// Returns whether `span` originates in a derive macro's expansion
pub fn in_derive_expansion(span: Span) -> bool {
if let Some(info) = span.ctxt().outer_expn_info() {
if let ExpnKind::Macro(MacroKind::Derive, _) = info.kind {
return true;
}
if let ExpnKind::Macro(MacroKind::Derive, _) = span.ctxt().outer_expn_data().kind {
return true;
}
false
}
8 changes: 4 additions & 4 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use errors::{Applicability, DiagnosticBuilder};
use std::fmt;
use syntax::ast;
use syntax::symbol::sym;
use syntax_pos::{DUMMY_SP, Span, ExpnInfo, ExpnKind};
use syntax_pos::{DUMMY_SP, Span, ExpnKind};

impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
pub fn report_fulfillment_errors(&self,
Expand All @@ -61,9 +61,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
// We want to ignore desugarings here: spans are equivalent even
// if one is the result of a desugaring and the other is not.
let mut span = error.obligation.cause.span;
if let Some(ExpnInfo { kind: ExpnKind::Desugaring(_), def_site, .. })
= span.ctxt().outer_expn_info() {
span = def_site;
let expn_data = span.ctxt().outer_expn_data();
if let ExpnKind::Desugaring(_) = expn_data.kind {
span = expn_data.call_site;
}

error_map.entry(span).or_default().push(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
projection_ty: ty::ProjectionTy::from_ref_and_name(
tcx,
trait_ref,
Ident::with_empty_ctxt(FN_OUTPUT_NAME),
Ident::with_dummy_span(FN_OUTPUT_NAME),
),
ty: ret_type
}
Expand Down
Loading