From 961ba8f9efbb51d80e7e73a609f6587c0ffa0623 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 16 Jun 2019 18:58:39 +0300 Subject: syntax: Factor out common fields from `SyntaxExtension` variants --- src/libsyntax/ext/base.rs | 148 ++++++++++++++++++------------ src/libsyntax/ext/derive.rs | 2 +- src/libsyntax/ext/expand.rs | 178 ++++++++++-------------------------- src/libsyntax/ext/tt/macro_rules.rs | 12 ++- 4 files changed, 142 insertions(+), 198 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 38b7dee40c4..04cef0bba24 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -15,6 +15,7 @@ use crate::tokenstream::{self, TokenStream}; use errors::{DiagnosticBuilder, DiagnosticId}; use smallvec::{smallvec, SmallVec}; use syntax_pos::{Span, MultiSpan, DUMMY_SP}; +use syntax_pos::hygiene::{ExpnInfo, ExpnFormat}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{self, Lrc}; @@ -548,37 +549,19 @@ impl MacroKind { } } -/// An enum representing the different kinds of syntax extensions. -pub enum SyntaxExtension { +/// A syntax extension kind. +pub enum SyntaxExtensionKind { /// A token-based function-like macro. - Bang { + Bang( /// An expander with signature TokenStream -> TokenStream. - expander: Box, - /// Whitelist of unstable features that are treated as stable inside this macro. - allow_internal_unstable: Option>, - /// Edition of the crate in which this macro is defined. - edition: Edition, - }, + Box, + ), /// An AST-based function-like macro. - LegacyBang { + LegacyBang( /// An expander with signature TokenStream -> AST. - expander: Box, - /// Some info about the macro's definition point. - def_info: Option<(ast::NodeId, Span)>, - /// Hygienic properties of identifiers produced by this macro. - transparency: Transparency, - /// Whitelist of unstable features that are treated as stable inside this macro. - allow_internal_unstable: Option>, - /// Suppresses the `unsafe_code` lint for code produced by this macro. - allow_internal_unsafe: bool, - /// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) for this macro. - local_inner_macros: bool, - /// The macro's feature name and tracking issue number if it is unstable. - unstable_feature: Option<(Symbol, u32)>, - /// Edition of the crate in which this macro is defined. - edition: Edition, - }, + Box, + ), /// A token-based attribute macro. Attr( @@ -586,8 +569,6 @@ pub enum SyntaxExtension { /// The first TokenSteam is the attribute itself, the second is the annotated item. /// The produced TokenSteam replaces the input TokenSteam. Box, - /// Edition of the crate in which this macro is defined. - Edition, ), /// An AST-based attribute macro. @@ -599,7 +580,8 @@ pub enum SyntaxExtension { ), /// A trivial attribute "macro" that does nothing, - /// only keeps the attribute and marks it as known. + /// only keeps the attribute and marks it as inert, + /// thus making it ineligible for further expansion. NonMacroAttr { /// Suppresses the `unused_attributes` lint for this attribute. mark_used: bool, @@ -610,10 +592,6 @@ pub enum SyntaxExtension { /// An expander with signature TokenStream -> TokenStream (not yet). /// The produced TokenSteam is appended to the input TokenSteam. Box, - /// Names of helper attributes registered by this macro. - Vec, - /// Edition of the crate in which this macro is defined. - Edition, ), /// An AST-based derive macro. @@ -624,42 +602,90 @@ pub enum SyntaxExtension { ), } +/// A struct representing a macro definition in "lowered" form ready for expansion. +pub struct SyntaxExtension { + /// A syntax extension kind. + pub kind: SyntaxExtensionKind, + /// Some info about the macro's definition point. + pub def_info: Option<(ast::NodeId, Span)>, + /// Hygienic properties of spans produced by this macro by default. + pub default_transparency: Transparency, + /// Whitelist of unstable features that are treated as stable inside this macro. + pub allow_internal_unstable: Option>, + /// Suppresses the `unsafe_code` lint for code produced by this macro. + pub allow_internal_unsafe: bool, + /// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) for this macro. + pub local_inner_macros: bool, + /// The macro's feature name and tracking issue number if it is unstable. + pub unstable_feature: Option<(Symbol, u32)>, + /// Names of helper attributes registered by this macro. + pub helper_attrs: Vec, + /// Edition of the crate in which this macro is defined. + pub edition: Edition, +} + +impl SyntaxExtensionKind { + /// When a syntax extension is constructed, + /// its transparency can often be inferred from its kind. + fn default_transparency(&self) -> Transparency { + match self { + SyntaxExtensionKind::Bang(..) | + SyntaxExtensionKind::Attr(..) | + SyntaxExtensionKind::Derive(..) | + SyntaxExtensionKind::NonMacroAttr { .. } => Transparency::Opaque, + SyntaxExtensionKind::LegacyBang(..) | + SyntaxExtensionKind::LegacyAttr(..) | + SyntaxExtensionKind::LegacyDerive(..) => Transparency::SemiTransparent, + } + } +} + impl SyntaxExtension { /// Returns which kind of macro calls this syntax extension. - pub fn kind(&self) -> MacroKind { - match *self { - SyntaxExtension::Bang { .. } | - SyntaxExtension::LegacyBang { .. } => MacroKind::Bang, - SyntaxExtension::Attr(..) | - SyntaxExtension::LegacyAttr(..) | - SyntaxExtension::NonMacroAttr { .. } => MacroKind::Attr, - SyntaxExtension::Derive(..) | - SyntaxExtension::LegacyDerive(..) => MacroKind::Derive, + pub fn macro_kind(&self) -> MacroKind { + match self.kind { + SyntaxExtensionKind::Bang(..) | + SyntaxExtensionKind::LegacyBang(..) => MacroKind::Bang, + SyntaxExtensionKind::Attr(..) | + SyntaxExtensionKind::LegacyAttr(..) | + SyntaxExtensionKind::NonMacroAttr { .. } => MacroKind::Attr, + SyntaxExtensionKind::Derive(..) | + SyntaxExtensionKind::LegacyDerive(..) => MacroKind::Derive, } } - pub fn default_transparency(&self) -> Transparency { - match *self { - SyntaxExtension::LegacyBang { transparency, .. } => transparency, - SyntaxExtension::Bang { .. } | - SyntaxExtension::Attr(..) | - SyntaxExtension::Derive(..) | - SyntaxExtension::NonMacroAttr { .. } => Transparency::Opaque, - SyntaxExtension::LegacyAttr(..) | - SyntaxExtension::LegacyDerive(..) => Transparency::SemiTransparent, + /// Constructs a syntax extension with default properties. + pub fn default(kind: SyntaxExtensionKind, edition: Edition) -> SyntaxExtension { + SyntaxExtension { + def_info: None, + default_transparency: kind.default_transparency(), + allow_internal_unstable: None, + allow_internal_unsafe: false, + local_inner_macros: false, + unstable_feature: None, + helper_attrs: Vec::new(), + edition, + kind, } } - pub fn edition(&self, default_edition: Edition) -> Edition { - match *self { - SyntaxExtension::Bang { edition, .. } | - SyntaxExtension::LegacyBang { edition, .. } | - SyntaxExtension::Attr(.., edition) | - SyntaxExtension::Derive(.., edition) => edition, - // Unstable legacy stuff - SyntaxExtension::NonMacroAttr { .. } | - SyntaxExtension::LegacyAttr(..) | - SyntaxExtension::LegacyDerive(..) => default_edition, + fn expn_format(&self, symbol: Symbol) -> ExpnFormat { + match self.kind { + SyntaxExtensionKind::Bang(..) | + SyntaxExtensionKind::LegacyBang(..) => ExpnFormat::MacroBang(symbol), + _ => ExpnFormat::MacroAttribute(symbol), + } + } + + crate fn expn_info(&self, call_site: Span, format: &str) -> ExpnInfo { + ExpnInfo { + call_site, + def_site: self.def_info.map(|(_, span)| span), + format: self.expn_format(Symbol::intern(format)), + allow_internal_unstable: self.allow_internal_unstable.clone(), + allow_internal_unsafe: self.allow_internal_unsafe, + local_inner_macros: self.local_inner_macros, + edition: self.edition, } } } diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index a2cf4a2a82d..33620cb80f9 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -64,7 +64,7 @@ pub fn add_derived_markers(cx: &mut ExtCtxt<'_>, span: Span, traits: &[ast::P call_site: span, def_site: None, format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)), - allow_internal_unstable: Some(vec![sym::rustc_attrs, sym::structural_match].into()), + allow_internal_unstable: Some([sym::rustc_attrs, sym::structural_match][..].into()), allow_internal_unsafe: false, local_inner_macros: false, edition: cx.parse_sess.edition, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 3fa96c60bff..4e759c5e528 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1,7 +1,7 @@ use crate::ast::{self, Block, Ident, LitKind, NodeId, PatKind, Path}; use crate::ast::{MacStmtStyle, StmtKind, ItemKind}; use crate::attr::{self, HasAttrs}; -use crate::source_map::{ExpnInfo, MacroBang, MacroAttribute, dummy_spanned, respan}; +use crate::source_map::{dummy_spanned, respan}; use crate::config::StripUnconfigured; use crate::ext::base::*; use crate::ext::derive::{add_derived_markers, collect_derives}; @@ -22,7 +22,6 @@ use crate::util::map_in_place::MapInPlace; use errors::{Applicability, FatalError}; use smallvec::{smallvec, SmallVec}; use syntax_pos::{Span, DUMMY_SP, FileName}; -use syntax_pos::hygiene::ExpnFormat; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; @@ -189,10 +188,10 @@ impl AstFragmentKind { } } -fn macro_bang_format(path: &ast::Path) -> ExpnFormat { - // We don't want to format a path using pretty-printing, - // `format!("{}", path)`, because that tries to insert - // line-breaks and is slow. +// We don't want to format a path using pretty-printing, +// `format!("{}", path)`, because that tries to insert +// line-breaks and is slow. +fn fast_print_path(path: &ast::Path) -> String { let mut path_str = String::with_capacity(64); for (i, segment) in path.segments.iter().enumerate() { if i != 0 { @@ -202,8 +201,7 @@ fn macro_bang_format(path: &ast::Path) -> ExpnFormat { path_str.push_str(&segment.ident.as_str()) } } - - MacroBang(Symbol::intern(&path_str)) + path_str } pub struct Invocation { @@ -388,8 +386,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { derives.push(mark); let item = match self.cx.resolver.resolve_macro_path( path, MacroKind::Derive, Mark::root(), Vec::new(), false) { - Ok(ext) => match *ext { - SyntaxExtension::LegacyDerive(..) => item_with_markers.clone(), + Ok(ext) => match ext.kind { + SyntaxExtensionKind::LegacyDerive(..) => item_with_markers.clone(), _ => item.clone(), }, _ => item.clone(), @@ -509,7 +507,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { fn expand_invoc(&mut self, invoc: Invocation, ext: &SyntaxExtension) -> Option { if invoc.fragment_kind == AstFragmentKind::ForeignItems && !self.cx.ecfg.macros_in_extern_enabled() { - if let SyntaxExtension::NonMacroAttr { .. } = *ext {} else { + if let SyntaxExtensionKind::NonMacroAttr { .. } = ext.kind {} else { emit_feature_err(&self.cx.parse_sess, sym::macros_in_extern, invoc.span(), GateIssue::Language, "macro invocations in `extern {}` blocks are experimental"); @@ -548,34 +546,25 @@ impl<'a, 'b> MacroExpander<'a, 'b> { _ => unreachable!(), }; - if let SyntaxExtension::NonMacroAttr { mark_used: false } = *ext {} else { - // Macro attrs are always used when expanded, - // non-macro attrs are considered used when the field says so. - attr::mark_used(&attr); - } - invoc.expansion_data.mark.set_expn_info(ExpnInfo { - call_site: attr.span, - def_site: None, - format: MacroAttribute(Symbol::intern(&attr.path.to_string())), - allow_internal_unstable: None, - allow_internal_unsafe: false, - local_inner_macros: false, - edition: ext.edition(self.cx.parse_sess.edition), - }); + let expn_info = ext.expn_info(attr.span, &fast_print_path(&attr.path)); + invoc.expansion_data.mark.set_expn_info(expn_info); - match *ext { - SyntaxExtension::NonMacroAttr { .. } => { + match &ext.kind { + SyntaxExtensionKind::NonMacroAttr { mark_used } => { attr::mark_known(&attr); + if *mark_used { + attr::mark_used(&attr); + } item.visit_attrs(|attrs| attrs.push(attr)); Some(invoc.fragment_kind.expect_from_annotatables(iter::once(item))) } - SyntaxExtension::LegacyAttr(ref mac) => { + SyntaxExtensionKind::LegacyAttr(expander) => { let meta = attr.parse_meta(self.cx.parse_sess) .map_err(|mut e| { e.emit(); }).ok()?; - let item = mac.expand(self.cx, attr.span, &meta, item); + let item = expander.expand(self.cx, attr.span, &meta, item); Some(invoc.fragment_kind.expect_from_annotatables(item)) } - SyntaxExtension::Attr(ref mac, ..) => { + SyntaxExtensionKind::Attr(expander) => { self.gate_proc_macro_attr_item(attr.span, &item); let item_tok = TokenTree::token(token::Interpolated(Lrc::new(match item { Annotatable::Item(item) => token::NtItem(item), @@ -586,13 +575,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Annotatable::Expr(expr) => token::NtExpr(expr), })), DUMMY_SP).into(); let input = self.extract_proc_macro_attr_input(attr.tokens, attr.span); - let tok_result = mac.expand(self.cx, attr.span, input, item_tok); + let tok_result = expander.expand(self.cx, attr.span, input, item_tok); let res = self.parse_ast_fragment(tok_result, invoc.fragment_kind, &attr.path, attr.span); self.gate_proc_macro_expansion(attr.span, &res); res } - SyntaxExtension::Derive(..) | SyntaxExtension::LegacyDerive(..) => { + SyntaxExtensionKind::Derive(..) | SyntaxExtensionKind::LegacyDerive(..) => { self.cx.span_err(attr.span, &format!("`{}` is a derive macro", attr.path)); self.cx.trace_macros_diag(); invoc.fragment_kind.dummy(attr.span) @@ -701,21 +690,13 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let path = &mac.node.path; let ident = ident.unwrap_or_else(|| Ident::invalid()); - let validate_and_set_expn_info = |this: &mut Self, // arg instead of capture - def_site_span: Option, - allow_internal_unstable, - allow_internal_unsafe, - local_inner_macros, - // can't infer this type - unstable_feature: Option<(Symbol, u32)>, - edition| { - + let validate_and_set_expn_info = |this: &mut Self| { // feature-gate the macro invocation - if let Some((feature, issue)) = unstable_feature { + if let Some((feature, issue)) = ext.unstable_feature { let crate_span = this.cx.current_expansion.crate_span.unwrap(); // don't stability-check macros in the same crate // (the only time this is null is for syntax extensions registered as macros) - if def_site_span.map_or(false, |def_span| !crate_span.contains(def_span)) + if ext.def_info.map_or(false, |(_, def_span)| !crate_span.contains(def_span)) && !span.allows_unstable(feature) && this.cx.ecfg.features.map_or(true, |feats| { // macro features will count as lib features @@ -734,62 +715,40 @@ impl<'a, 'b> MacroExpander<'a, 'b> { this.cx.trace_macros_diag(); return Err(kind.dummy(span)); } - mark.set_expn_info(ExpnInfo { - call_site: span, - def_site: def_site_span, - format: macro_bang_format(path), - allow_internal_unstable, - allow_internal_unsafe, - local_inner_macros, - edition, - }); + mark.set_expn_info(ext.expn_info(span, &fast_print_path(path))); Ok(()) }; - let opt_expanded = match *ext { - SyntaxExtension::LegacyBang { - ref expander, - def_info, - ref allow_internal_unstable, - allow_internal_unsafe, - local_inner_macros, - unstable_feature, - edition, - .. - } => { - if let Err(dummy_span) = validate_and_set_expn_info(self, def_info.map(|(_, s)| s), - allow_internal_unstable.clone(), - allow_internal_unsafe, - local_inner_macros, - unstable_feature, - edition) { + let opt_expanded = match &ext.kind { + SyntaxExtensionKind::LegacyBang(expander) => { + if let Err(dummy_span) = validate_and_set_expn_info(self) { dummy_span } else { kind.make_from(expander.expand( self.cx, span, mac.node.stream(), - def_info.map(|(_, s)| s), + ext.def_info.map(|(_, s)| s), )) } } - SyntaxExtension::Attr(..) | - SyntaxExtension::LegacyAttr(..) | - SyntaxExtension::NonMacroAttr { .. } => { + SyntaxExtensionKind::Attr(..) | + SyntaxExtensionKind::LegacyAttr(..) | + SyntaxExtensionKind::NonMacroAttr { .. } => { self.cx.span_err(path.span, &format!("`{}` can only be used in attributes", path)); self.cx.trace_macros_diag(); kind.dummy(span) } - SyntaxExtension::Derive(..) | SyntaxExtension::LegacyDerive(..) => { + SyntaxExtensionKind::Derive(..) | SyntaxExtensionKind::LegacyDerive(..) => { self.cx.span_err(path.span, &format!("`{}` is a derive macro", path)); self.cx.trace_macros_diag(); kind.dummy(span) } - SyntaxExtension::Bang { ref expander, ref allow_internal_unstable, edition } => { + SyntaxExtensionKind::Bang(expander) => { if ident.name != kw::Invalid { let msg = format!("macro {}! expects no ident argument, given '{}'", path, ident); @@ -798,19 +757,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { kind.dummy(span) } else { self.gate_proc_macro_expansion_kind(span, kind); - invoc.expansion_data.mark.set_expn_info(ExpnInfo { - call_site: span, - // FIXME procedural macros do not have proper span info - // yet, when they do, we should use it here. - def_site: None, - format: macro_bang_format(path), - // FIXME probably want to follow macro_rules macros here. - allow_internal_unstable: allow_internal_unstable.clone(), - allow_internal_unsafe: false, - local_inner_macros: false, - edition, - }); - + let expn_info = ext.expn_info(span, &fast_print_path(path)); + invoc.expansion_data.mark.set_expn_info(expn_info); let tok_result = expander.expand(self.cx, span, mac.node.stream()); let result = self.parse_ast_fragment(tok_result, kind, path, span); self.gate_proc_macro_expansion(span, &result); @@ -867,55 +815,23 @@ impl<'a, 'b> MacroExpander<'a, 'b> { return None; } - let pretty_name = Symbol::intern(&format!("derive({})", path)); - let span = path.span; - let attr = ast::Attribute { - path, span, - tokens: TokenStream::empty(), - // irrelevant: - id: ast::AttrId(0), style: ast::AttrStyle::Outer, is_sugared_doc: false, - }; - - let mut expn_info = ExpnInfo { - call_site: span, - def_site: None, - format: MacroAttribute(pretty_name), - allow_internal_unstable: None, - allow_internal_unsafe: false, - local_inner_macros: false, - edition: ext.edition(self.cx.parse_sess.edition), - }; - - match ext { - SyntaxExtension::Derive(expander, ..) | SyntaxExtension::LegacyDerive(expander) => { - let meta = match ext { - SyntaxExtension::Derive(..) => ast::MetaItem { // FIXME(jseyfried) avoid this - path: Path::from_ident(Ident::invalid()), - span: DUMMY_SP, - node: ast::MetaItemKind::Word, - }, - _ => { - expn_info.allow_internal_unstable = Some(vec![ - sym::rustc_attrs, - Symbol::intern("derive_clone_copy"), - Symbol::intern("derive_eq"), - // RustcDeserialize and RustcSerialize - Symbol::intern("libstd_sys_internals"), - ].into()); - attr.meta()? - } - }; - + match &ext.kind { + SyntaxExtensionKind::Derive(expander) | + SyntaxExtensionKind::LegacyDerive(expander) => { + let expn_info = + ext.expn_info(path.span, &format!("derive({})", fast_print_path(&path))); invoc.expansion_data.mark.set_expn_info(expn_info); - let span = span.with_ctxt(self.cx.backtrace()); + + let meta = ast::MetaItem { node: ast::MetaItemKind::Word, span: path.span, path }; + let span = meta.span.with_ctxt(self.cx.backtrace()); let items = expander.expand(self.cx, span, &meta, item); Some(invoc.fragment_kind.expect_from_annotatables(items)) } _ => { - let msg = &format!("macro `{}` may not be used for derive attributes", attr.path); - self.cx.span_err(span, msg); + let msg = &format!("macro `{}` may not be used for derive attributes", path); + self.cx.span_err(path.span, msg); self.cx.trace_macros_diag(); - invoc.fragment_kind.dummy(span) + invoc.fragment_kind.dummy(path.span) } } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 22745a1a76d..7f051c260ec 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -1,6 +1,7 @@ use crate::{ast, attr}; use crate::edition::Edition; -use crate::ext::base::{DummyResult, ExtCtxt, MacResult, SyntaxExtension, TTMacroExpander}; +use crate::ext::base::{SyntaxExtension, SyntaxExtensionKind}; +use crate::ext::base::{DummyResult, ExtCtxt, MacResult, TTMacroExpander}; use crate::ext::expand::{AstFragment, AstFragmentKind}; use crate::ext::hygiene::Transparency; use crate::ext::tt::macro_parser::{Success, Error, Failure}; @@ -376,7 +377,7 @@ pub fn compile( valid, }); - let transparency = if attr::contains_name(&def.attrs, sym::rustc_transparent_macro) { + let default_transparency = if attr::contains_name(&def.attrs, sym::rustc_transparent_macro) { Transparency::Transparent } else if body.legacy { Transparency::SemiTransparent @@ -426,14 +427,15 @@ pub fn compile( } }); - SyntaxExtension::LegacyBang { - expander, + SyntaxExtension { + kind: SyntaxExtensionKind::LegacyBang(expander), def_info: Some((def.id, def.span)), - transparency, + default_transparency, allow_internal_unstable, allow_internal_unsafe, local_inner_macros, unstable_feature, + helper_attrs: Vec::new(), edition, } } -- cgit 1.4.1-3-g733a5 From 085a8d03750b524a34bf14adc0c9a36a2503e016 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 17 Jun 2019 11:10:48 +0300 Subject: syntax: Remove `DummyResolver` --- src/libsyntax/ext/base.rs | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 04cef0bba24..cc5a91465ae 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -725,31 +725,6 @@ impl Determinacy { } } -pub struct DummyResolver; - -impl Resolver for DummyResolver { - fn next_node_id(&mut self) -> ast::NodeId { ast::DUMMY_NODE_ID } - - fn get_module_scope(&mut self, _id: ast::NodeId) -> Mark { Mark::root() } - - fn resolve_dollar_crates(&mut self, _fragment: &AstFragment) {} - fn visit_ast_fragment_with_placeholders(&mut self, _invoc: Mark, _fragment: &AstFragment, - _derives: &[Mark]) {} - fn add_builtin(&mut self, _ident: ast::Ident, _ext: Lrc) {} - - fn resolve_imports(&mut self) {} - fn resolve_macro_invocation(&mut self, _invoc: &Invocation, _invoc_id: Mark, _force: bool) - -> Result>, Determinacy> { - Err(Determinacy::Determined) - } - fn resolve_macro_path(&mut self, _path: &ast::Path, _kind: MacroKind, _invoc_id: Mark, - _derives_in_scope: Vec, _force: bool) - -> Result, Determinacy> { - Err(Determinacy::Determined) - } - fn check_unused_macros(&self) {} -} - #[derive(Clone)] pub struct ModuleData { pub mod_path: Vec, -- cgit 1.4.1-3-g733a5 From 8ec502eecdccec643ae6631a323dc6f38b490269 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 17 Jun 2019 22:18:56 +0300 Subject: syntax: Introduce `default`/`with_unstable` constructors for `ExpnInfo` --- src/librustc/hir/lowering.rs | 12 ++++-------- src/librustc_allocator/expand.rs | 21 +++++++-------------- src/libsyntax/ext/derive.rs | 13 ++++--------- src/libsyntax/std_inject.rs | 12 +++--------- src/libsyntax/test.rs | 13 ++++--------- src/libsyntax_ext/proc_macro_decls.rs | 15 ++++----------- src/libsyntax_ext/test.rs | 15 +++++---------- src/libsyntax_ext/test_case.rs | 15 +++++---------- src/libsyntax_pos/hygiene.rs | 23 +++++++++++++++++++++++ 9 files changed, 59 insertions(+), 80 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index a491b1a099b..0edf407f7c9 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -62,14 +62,14 @@ use syntax::errors; use syntax::ext::hygiene::{Mark, SyntaxContext}; use syntax::print::pprust; use syntax::ptr::P; -use syntax::source_map::{self, respan, CompilerDesugaringKind, Spanned}; +use syntax::source_map::{self, respan, ExpnInfo, CompilerDesugaringKind, Spanned}; use syntax::source_map::CompilerDesugaringKind::IfTemporary; use syntax::std_inject; use syntax::symbol::{kw, sym, Symbol}; use syntax::tokenstream::{TokenStream, TokenTree}; use syntax::parse::token::{self, Token}; use syntax::visit::{self, Visitor}; -use syntax_pos::{DUMMY_SP, edition, Span}; +use syntax_pos::{DUMMY_SP, Span}; const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF; @@ -853,14 +853,10 @@ impl<'a> LoweringContext<'a> { allow_internal_unstable: Option>, ) -> Span { let mark = Mark::fresh(Mark::root()); - mark.set_expn_info(source_map::ExpnInfo { - call_site: span, + mark.set_expn_info(ExpnInfo { def_site: Some(span), - format: source_map::CompilerDesugaring(reason), allow_internal_unstable, - allow_internal_unsafe: false, - local_inner_macros: false, - edition: edition::Edition::from_session(), + ..ExpnInfo::default(source_map::CompilerDesugaring(reason), span, self.sess.edition()) }); span.with_ctxt(SyntaxContext::empty().apply_mark(mark)) } diff --git a/src/librustc_allocator/expand.rs b/src/librustc_allocator/expand.rs index ecc165ca5ea..d402b0ddf6e 100644 --- a/src/librustc_allocator/expand.rs +++ b/src/librustc_allocator/expand.rs @@ -19,7 +19,7 @@ use syntax::{ mut_visit::{self, MutVisitor}, parse::ParseSess, ptr::P, - symbol::{kw, sym, Symbol} + symbol::{kw, sym} }; use syntax_pos::Span; @@ -58,11 +58,10 @@ impl MutVisitor for ExpandAllocatorDirectives<'_> { fn flat_map_item(&mut self, item: P) -> SmallVec<[P; 1]> { debug!("in submodule {}", self.in_submod); - let name = if attr::contains_name(&item.attrs, sym::global_allocator) { - "global_allocator" - } else { + if !attr::contains_name(&item.attrs, sym::global_allocator) { return mut_visit::noop_flat_map_item(item, self); - }; + } + match item.node { ItemKind::Static(..) => {} _ => { @@ -87,15 +86,9 @@ impl MutVisitor for ExpandAllocatorDirectives<'_> { // Create a fresh Mark for the new macro expansion we are about to do let mark = Mark::fresh(Mark::root()); - mark.set_expn_info(ExpnInfo { - call_site: item.span, // use the call site of the static - def_site: None, - format: MacroAttribute(Symbol::intern(name)), - allow_internal_unstable: Some([sym::rustc_attrs][..].into()), - allow_internal_unsafe: false, - local_inner_macros: false, - edition: self.sess.edition, - }); + mark.set_expn_info(ExpnInfo::with_unstable( + MacroAttribute(sym::global_allocator), item.span, self.sess.edition, &[sym::rustc_attrs] + )); // Tie the span to the macro expansion info we just created let span = item.span.with_ctxt(SyntaxContext::empty().apply_mark(mark)); diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index 33620cb80f9..abc451c96ae 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -60,15 +60,10 @@ pub fn add_derived_markers(cx: &mut ExtCtxt<'_>, span: Span, traits: &[ast::P } pretty_name.push(')'); - cx.current_expansion.mark.set_expn_info(ExpnInfo { - call_site: span, - def_site: None, - format: ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)), - allow_internal_unstable: Some([sym::rustc_attrs, sym::structural_match][..].into()), - allow_internal_unsafe: false, - local_inner_macros: false, - edition: cx.parse_sess.edition, - }); + cx.current_expansion.mark.set_expn_info(ExpnInfo::with_unstable( + ExpnFormat::MacroAttribute(Symbol::intern(&pretty_name)), span, cx.parse_sess.edition, + &[sym::rustc_attrs, sym::structural_match], + )); let span = span.with_ctxt(cx.backtrace()); item.visit_attrs(|attrs| { diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 9072ad7b30f..6630bf90815 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -16,15 +16,9 @@ use syntax_pos::{DUMMY_SP, Span}; /// The expanded code uses the unstable `#[prelude_import]` attribute. fn ignored_span(sp: Span, edition: Edition) -> Span { let mark = Mark::fresh(Mark::root()); - mark.set_expn_info(ExpnInfo { - call_site: DUMMY_SP, - def_site: None, - format: MacroAttribute(Symbol::intern("std_inject")), - allow_internal_unstable: Some([sym::prelude_import][..].into()), - allow_internal_unsafe: false, - local_inner_macros: false, - edition, - }); + mark.set_expn_info(ExpnInfo::with_unstable( + MacroAttribute(Symbol::intern("std_inject")), sp, edition, &[sym::prelude_import] + )); sp.with_ctxt(SyntaxContext::empty().apply_mark(mark)) } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 0e1b10c14f1..f90b76721ee 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -280,15 +280,10 @@ fn generate_test_harness(sess: &ParseSess, test_runner }; - mark.set_expn_info(ExpnInfo { - call_site: DUMMY_SP, - def_site: None, - format: MacroAttribute(sym::test_case), - allow_internal_unstable: Some([sym::main, sym::test, sym::rustc_attrs][..].into()), - allow_internal_unsafe: false, - local_inner_macros: false, - edition: sess.edition, - }); + mark.set_expn_info(ExpnInfo::with_unstable( + MacroAttribute(sym::test_case), DUMMY_SP, sess.edition, + &[sym::main, sym::test, sym::rustc_attrs], + )); TestHarnessGenerator { cx, diff --git a/src/libsyntax_ext/proc_macro_decls.rs b/src/libsyntax_ext/proc_macro_decls.rs index cdef5c6a9f4..45e65288a24 100644 --- a/src/libsyntax_ext/proc_macro_decls.rs +++ b/src/libsyntax_ext/proc_macro_decls.rs @@ -347,17 +347,10 @@ fn mk_decls( custom_macros: &[ProcMacroDef], ) -> P { let mark = Mark::fresh(Mark::root()); - mark.set_expn_info(ExpnInfo { - call_site: DUMMY_SP, - def_site: None, - format: MacroAttribute(sym::proc_macro), - allow_internal_unstable: Some([ - sym::rustc_attrs, Symbol::intern("proc_macro_internals") - ][..].into()), - allow_internal_unsafe: false, - local_inner_macros: false, - edition: cx.parse_sess.edition, - }); + mark.set_expn_info(ExpnInfo::with_unstable( + MacroAttribute(sym::proc_macro), DUMMY_SP, cx.parse_sess.edition, + &[sym::rustc_attrs, Symbol::intern("proc_macro_internals")], + )); let span = DUMMY_SP.apply_mark(mark); let hidden = cx.meta_list_item_word(span, sym::hidden); diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index a8c8456a3bc..24d3055e711 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -8,7 +8,7 @@ use syntax::attr; use syntax::ast; use syntax::print::pprust; use syntax::symbol::{Symbol, sym}; -use syntax_pos::{DUMMY_SP, Span}; +use syntax_pos::Span; use syntax::source_map::{ExpnInfo, MacroAttribute}; use std::iter; @@ -62,15 +62,10 @@ pub fn expand_test_or_bench( let (sp, attr_sp) = { let mark = Mark::fresh(Mark::root()); - mark.set_expn_info(ExpnInfo { - call_site: DUMMY_SP, - def_site: None, - format: MacroAttribute(sym::test), - allow_internal_unstable: Some([sym::rustc_attrs, sym::test][..].into()), - allow_internal_unsafe: false, - local_inner_macros: false, - edition: cx.parse_sess.edition, - }); + mark.set_expn_info(ExpnInfo::with_unstable( + MacroAttribute(sym::test), attr_sp, cx.parse_sess.edition, + &[sym::rustc_attrs, sym::test], + )); (item.span.with_ctxt(SyntaxContext::empty().apply_mark(mark)), attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(mark))) }; diff --git a/src/libsyntax_ext/test_case.rs b/src/libsyntax_ext/test_case.rs index ce17cf2a6e7..6e3bc05b65e 100644 --- a/src/libsyntax_ext/test_case.rs +++ b/src/libsyntax_ext/test_case.rs @@ -15,7 +15,7 @@ use syntax::ext::hygiene::{Mark, SyntaxContext}; use syntax::ast; use syntax::source_map::respan; use syntax::symbol::sym; -use syntax_pos::{DUMMY_SP, Span}; +use syntax_pos::Span; use syntax::source_map::{ExpnInfo, MacroAttribute}; use syntax::feature_gate; @@ -37,15 +37,10 @@ pub fn expand( let sp = { let mark = Mark::fresh(Mark::root()); - mark.set_expn_info(ExpnInfo { - call_site: DUMMY_SP, - def_site: None, - format: MacroAttribute(sym::test_case), - allow_internal_unstable: Some([sym::test, sym::rustc_attrs][..].into()), - allow_internal_unsafe: false, - local_inner_macros: false, - edition: ecx.parse_sess.edition, - }); + mark.set_expn_info(ExpnInfo::with_unstable( + MacroAttribute(sym::test_case), attr_sp, ecx.parse_sess.edition, + &[sym::test, sym::rustc_attrs], + )); attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(mark)) }; diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index b827416ab53..e9a912ddbc2 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -682,6 +682,29 @@ pub struct ExpnInfo { pub edition: Edition, } +impl ExpnInfo { + /// Constructs an expansion info with default properties. + pub fn default(format: ExpnFormat, call_site: Span, edition: Edition) -> ExpnInfo { + ExpnInfo { + call_site, + def_site: None, + format, + allow_internal_unstable: None, + allow_internal_unsafe: false, + local_inner_macros: false, + edition, + } + } + + pub fn with_unstable(format: ExpnFormat, call_site: Span, edition: Edition, + allow_internal_unstable: &[Symbol]) -> ExpnInfo { + ExpnInfo { + allow_internal_unstable: Some(allow_internal_unstable.into()), + ..ExpnInfo::default(format, call_site, edition) + } + } +} + /// The source of expansion. #[derive(Clone, Hash, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum ExpnFormat { -- cgit 1.4.1-3-g733a5 From 2de2278f1a356cba63300cee0bca49ad8f4905ab Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 17 Jun 2019 23:55:22 +0300 Subject: syntax: Move `default_transparency` into `ExpnInfo` --- src/librustc/ich/impls_syntax.rs | 9 ++++++++- src/librustc_resolve/macros.rs | 1 - src/libsyntax/ext/base.rs | 3 ++- src/libsyntax_pos/hygiene.rs | 42 ++++++++++++++++------------------------ 4 files changed, 27 insertions(+), 28 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 4f618457d6c..9430661f75a 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -391,10 +391,17 @@ impl_stable_hash_for!(enum ::syntax::ast::MetaItemKind { NameValue(lit) }); +impl_stable_hash_for!(enum ::syntax_pos::hygiene::Transparency { + Transparent, + SemiTransparent, + Opaque, +}); + impl_stable_hash_for!(struct ::syntax_pos::hygiene::ExpnInfo { call_site, - def_site, format, + def_site, + default_transparency, allow_internal_unstable, allow_internal_unsafe, local_inner_macros, diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 02342d212eb..a7c98842fa3 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -226,7 +226,6 @@ impl<'a> base::Resolver for Resolver<'a> { self.macro_def_scope(invoc.expansion_data.mark).normal_ancestor_id; self.definitions.add_parent_module_of_macro_def(invoc.expansion_data.mark, normal_module_def_id); - invoc.expansion_data.mark.set_default_transparency(ext.default_transparency); } Ok(Some(ext)) diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index cc5a91465ae..e0fbdedd24b 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -680,8 +680,9 @@ impl SyntaxExtension { crate fn expn_info(&self, call_site: Span, format: &str) -> ExpnInfo { ExpnInfo { call_site, - def_site: self.def_info.map(|(_, span)| span), format: self.expn_format(Symbol::intern(format)), + def_site: self.def_info.map(|(_, span)| span), + default_transparency: self.default_transparency, allow_internal_unstable: self.allow_internal_unstable.clone(), allow_internal_unsafe: self.allow_internal_unsafe, local_inner_macros: self.local_inner_macros, diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index e9a912ddbc2..67b6e9da477 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -59,13 +59,12 @@ pub struct Mark(u32); #[derive(Clone, Debug)] struct MarkData { parent: Mark, - default_transparency: Transparency, expn_info: Option, } /// A property of a macro expansion that determines how identifiers /// produced by that expansion are resolved. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug, RustcEncodable, RustcDecodable)] pub enum Transparency { /// Identifier produced by a transparent expansion is always resolved at call-site. /// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this. @@ -85,12 +84,7 @@ pub enum Transparency { impl Mark { pub fn fresh(parent: Mark) -> Self { HygieneData::with(|data| { - data.marks.push(MarkData { - parent, - // By default expansions behave like `macro_rules`. - default_transparency: Transparency::SemiTransparent, - expn_info: None, - }); + data.marks.push(MarkData { parent, expn_info: None }); Mark(data.marks.len() as u32 - 1) }) } @@ -126,12 +120,6 @@ impl Mark { HygieneData::with(|data| data.marks[self.0 as usize].expn_info = Some(info)) } - #[inline] - pub fn set_default_transparency(self, transparency: Transparency) { - assert_ne!(self, Mark::root()); - HygieneData::with(|data| data.marks[self.0 as usize].default_transparency = transparency) - } - pub fn is_descendant_of(self, ancestor: Mark) -> bool { HygieneData::with(|data| data.is_descendant_of(self, ancestor)) } @@ -172,9 +160,8 @@ impl Mark { #[inline] pub fn looks_like_proc_macro_derive(self) -> bool { HygieneData::with(|data| { - let mark_data = &data.marks[self.0 as usize]; - if mark_data.default_transparency == Transparency::Opaque { - if let Some(expn_info) = &mark_data.expn_info { + if data.default_transparency(self) == Transparency::Opaque { + if let Some(expn_info) = &data.marks[self.0 as usize].expn_info { if let ExpnFormat::MacroAttribute(name) = expn_info.format { if name.as_str().starts_with("derive(") { return true; @@ -199,9 +186,6 @@ impl HygieneData { HygieneData { marks: vec![MarkData { parent: Mark::root(), - // If the root is opaque, then loops searching for an opaque mark - // will automatically stop after reaching it. - default_transparency: Transparency::Opaque, expn_info: None, }], syntax_contexts: vec![SyntaxContextData { @@ -235,7 +219,9 @@ impl HygieneData { } fn default_transparency(&self, mark: Mark) -> Transparency { - self.marks[mark.0 as usize].default_transparency + self.marks[mark.0 as usize].expn_info.as_ref().map_or( + Transparency::SemiTransparent, |einfo| einfo.default_transparency + ) } fn modern(&self, ctxt: SyntaxContext) -> SyntaxContext { @@ -427,7 +413,6 @@ impl SyntaxContext { HygieneData::with(|data| { data.marks.push(MarkData { parent: Mark::root(), - default_transparency: Transparency::SemiTransparent, expn_info: Some(expansion_info), }); @@ -651,6 +636,7 @@ impl fmt::Debug for SyntaxContext { /// Extra information for tracking spans of macro and syntax sugar expansion #[derive(Clone, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct ExpnInfo { + // --- The part unique to each expansion. /// The location of the actual macro invocation or syntax sugar , e.g. /// `let x = foo!();` or `if let Some(y) = x {}` /// @@ -661,13 +647,18 @@ pub struct ExpnInfo { /// call_site span would have its own ExpnInfo, with the call_site /// pointing to the `foo!` invocation. pub call_site: Span, + /// The format with which the macro was invoked. + pub format: ExpnFormat, + + // --- The part specific to the macro/desugaring definition. + // --- FIXME: Share it between expansions with the same definition. /// The span of the macro definition itself. The macro may not /// have a sensible definition span (e.g., something defined /// completely inside libsyntax) in which case this is None. /// This span serves only informational purpose and is not used for resolution. pub def_site: Option, - /// The format with which the macro was invoked. - pub format: ExpnFormat, + /// Transparency used by `apply_mark` for mark with this expansion info by default. + pub default_transparency: Transparency, /// List of #[unstable]/feature-gated features that the macro is allowed to use /// internally without forcing the whole crate to opt-in /// to them. @@ -687,8 +678,9 @@ impl ExpnInfo { pub fn default(format: ExpnFormat, call_site: Span, edition: Edition) -> ExpnInfo { ExpnInfo { call_site, - def_site: None, format, + def_site: None, + default_transparency: Transparency::SemiTransparent, allow_internal_unstable: None, allow_internal_unsafe: false, local_inner_macros: false, -- cgit 1.4.1-3-g733a5 From e152554e11ff44b1a08e21a8416e1fc18504764e Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 18 Jun 2019 10:48:44 +0300 Subject: resolve/expand: Move expansion info setting to a single earlier point --- src/librustc_resolve/macros.rs | 31 ++++++++++++++++++++++++++----- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/expand.rs | 32 +++----------------------------- 3 files changed, 30 insertions(+), 35 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index a7c98842fa3..d2fec0ed622 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -114,6 +114,22 @@ fn sub_namespace_match(candidate: Option, requirement: Option String { + let mut path_str = String::with_capacity(64); + for (i, segment) in path.segments.iter().enumerate() { + if i != 0 { + path_str.push_str("::"); + } + if segment.ident.name != kw::PathRoot { + path_str.push_str(&segment.ident.as_str()) + } + } + path_str +} + impl<'a> base::Resolver for Resolver<'a> { fn next_node_id(&mut self) -> ast::NodeId { self.session.next_node_id() @@ -209,14 +225,19 @@ impl<'a> base::Resolver for Resolver<'a> { let parent_scope = self.invoc_parent_scope(invoc_id, derives_in_scope); let (res, ext) = match self.resolve_macro_to_res(path, kind, &parent_scope, true, force) { Ok((res, ext)) => (res, ext), - Err(Determinacy::Determined) if kind == MacroKind::Attr => { - // Replace unresolved attributes with used inert attributes for better recovery. - return Ok(Some(self.non_macro_attr(true))); - } + // Replace unresolved attributes with used inert attributes for better recovery. + Err(Determinacy::Determined) if kind == MacroKind::Attr => + (Res::Err, self.non_macro_attr(true)), Err(determinacy) => return Err(determinacy), }; - if let Res::Def(DefKind::Macro(_), def_id) = res { + let format = match kind { + MacroKind::Derive => format!("derive({})", fast_print_path(path)), + _ => fast_print_path(path), + }; + invoc.expansion_data.mark.set_expn_info(ext.expn_info(invoc.span(), &format)); + + if let Res::Def(_, def_id) = res { if after_derive { self.session.span_err(invoc.span(), "macro attributes must be placed before `#[derive]`"); diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e0fbdedd24b..318a5a3a82a 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -677,7 +677,7 @@ impl SyntaxExtension { } } - crate fn expn_info(&self, call_site: Span, format: &str) -> ExpnInfo { + pub fn expn_info(&self, call_site: Span, format: &str) -> ExpnInfo { ExpnInfo { call_site, format: self.expn_format(Symbol::intern(format)), diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 4e759c5e528..7154cc409f2 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -188,22 +188,6 @@ impl AstFragmentKind { } } -// We don't want to format a path using pretty-printing, -// `format!("{}", path)`, because that tries to insert -// line-breaks and is slow. -fn fast_print_path(path: &ast::Path) -> String { - let mut path_str = String::with_capacity(64); - for (i, segment) in path.segments.iter().enumerate() { - if i != 0 { - path_str.push_str("::"); - } - if segment.ident.name != kw::PathRoot { - path_str.push_str(&segment.ident.as_str()) - } - } - path_str -} - pub struct Invocation { pub kind: InvocationKind, fragment_kind: AstFragmentKind, @@ -546,9 +530,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { _ => unreachable!(), }; - let expn_info = ext.expn_info(attr.span, &fast_print_path(&attr.path)); - invoc.expansion_data.mark.set_expn_info(expn_info); - match &ext.kind { SyntaxExtensionKind::NonMacroAttr { mark_used } => { attr::mark_known(&attr); @@ -682,7 +663,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { invoc: Invocation, ext: &SyntaxExtension) -> Option { - let (mark, kind) = (invoc.expansion_data.mark, invoc.fragment_kind); + let kind = invoc.fragment_kind; let (mac, ident, span) = match invoc.kind { InvocationKind::Bang { mac, ident, span } => (mac, ident, span), _ => unreachable!(), @@ -690,7 +671,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let path = &mac.node.path; let ident = ident.unwrap_or_else(|| Ident::invalid()); - let validate_and_set_expn_info = |this: &mut Self| { + let validate = |this: &mut Self| { // feature-gate the macro invocation if let Some((feature, issue)) = ext.unstable_feature { let crate_span = this.cx.current_expansion.crate_span.unwrap(); @@ -715,13 +696,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> { this.cx.trace_macros_diag(); return Err(kind.dummy(span)); } - mark.set_expn_info(ext.expn_info(span, &fast_print_path(path))); Ok(()) }; let opt_expanded = match &ext.kind { SyntaxExtensionKind::LegacyBang(expander) => { - if let Err(dummy_span) = validate_and_set_expn_info(self) { + if let Err(dummy_span) = validate(self) { dummy_span } else { kind.make_from(expander.expand( @@ -757,8 +737,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { kind.dummy(span) } else { self.gate_proc_macro_expansion_kind(span, kind); - let expn_info = ext.expn_info(span, &fast_print_path(path)); - invoc.expansion_data.mark.set_expn_info(expn_info); let tok_result = expander.expand(self.cx, span, mac.node.stream()); let result = self.parse_ast_fragment(tok_result, kind, path, span); self.gate_proc_macro_expansion(span, &result); @@ -818,10 +796,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { match &ext.kind { SyntaxExtensionKind::Derive(expander) | SyntaxExtensionKind::LegacyDerive(expander) => { - let expn_info = - ext.expn_info(path.span, &format!("derive({})", fast_print_path(&path))); - invoc.expansion_data.mark.set_expn_info(expn_info); - let meta = ast::MetaItem { node: ast::MetaItemKind::Word, span: path.span, path }; let span = meta.span.with_ctxt(self.cx.backtrace()); let items = expander.expand(self.cx, span, &meta, item); -- cgit 1.4.1-3-g733a5 From b25b466a887d8ceaef533e542431fdec7e70f10f Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 14 Jun 2019 19:39:39 +0300 Subject: rustc: remove 'x: 'y bounds (except from comments/strings). --- src/librustc/cfg/construct.rs | 2 +- src/librustc/cfg/graphviz.rs | 2 +- src/librustc/dep_graph/dep_node.rs | 4 ++-- src/librustc/hir/intravisit.rs | 2 +- src/librustc/hir/lowering.rs | 8 +++---- src/librustc/hir/map/hir_id_validator.rs | 12 +++++----- src/librustc/infer/at.rs | 4 ++-- src/librustc/infer/canonical/canonicalizer.rs | 2 +- src/librustc/infer/combine.rs | 4 ++-- src/librustc/infer/equate.rs | 2 +- .../infer/error_reporting/nice_region_error/mod.rs | 2 +- src/librustc/infer/freshen.rs | 2 +- src/librustc/infer/fudge.rs | 2 +- src/librustc/infer/glb.rs | 2 +- src/librustc/infer/lattice.rs | 4 ++-- .../infer/lexical_region_resolve/graphviz.rs | 2 +- src/librustc/infer/lexical_region_resolve/mod.rs | 2 +- src/librustc/infer/lub.rs | 2 +- src/librustc/infer/mod.rs | 2 +- src/librustc/infer/nll_relate/mod.rs | 6 ++--- src/librustc/infer/opaque_types/mod.rs | 2 +- src/librustc/infer/outlives/env.rs | 2 +- src/librustc/infer/outlives/obligations.rs | 2 +- src/librustc/infer/outlives/verify.rs | 2 +- src/librustc/infer/resolve.rs | 8 +++---- src/librustc/infer/sub.rs | 2 +- src/librustc/lint/context.rs | 4 ++-- src/librustc/middle/dead.rs | 4 ++-- src/librustc/middle/entry.rs | 2 +- src/librustc/middle/expr_use_visitor.rs | 2 +- src/librustc/middle/free_region.rs | 2 +- src/librustc/middle/liveness.rs | 4 ++-- src/librustc/middle/reachable.rs | 6 ++--- src/librustc/middle/resolve_lifetime.rs | 4 ++-- src/librustc/middle/stability.rs | 8 +++---- src/librustc/middle/weak_lang_items.rs | 2 +- src/librustc/mir/mod.rs | 4 ++-- src/librustc/mir/traversal.rs | 6 ++--- src/librustc/traits/error_reporting.rs | 2 +- src/librustc/traits/fulfill.rs | 2 +- src/librustc/traits/project.rs | 2 +- src/librustc/traits/query/normalize.rs | 2 +- src/librustc/traits/select.rs | 10 ++++----- src/librustc/ty/query/on_disk_cache.rs | 2 +- src/librustc/ty/query/plumbing.rs | 4 ++-- src/librustc/ty/wf.rs | 2 +- src/librustc_borrowck/borrowck/check_loans.rs | 2 +- .../borrowck/gather_loans/gather_moves.rs | 6 ++--- .../borrowck/gather_loans/lifetime.rs | 2 +- src/librustc_borrowck/borrowck/gather_loans/mod.rs | 2 +- .../borrowck/gather_loans/restrictions.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_borrowck/graphviz.rs | 2 +- src/librustc_codegen_llvm/builder.rs | 2 +- src/librustc_codegen_llvm/context.rs | 2 +- src/librustc_codegen_llvm/lib.rs | 2 +- src/librustc_codegen_ssa/README.md | 10 ++++----- src/librustc_codegen_ssa/base.rs | 24 ++++++++++---------- src/librustc_codegen_ssa/common.rs | 8 +++---- src/librustc_codegen_ssa/glue.rs | 2 +- src/librustc_codegen_ssa/meth.rs | 2 +- src/librustc_codegen_ssa/mir/analyze.rs | 6 ++--- src/librustc_codegen_ssa/mir/block.rs | 4 ++-- src/librustc_codegen_ssa/mir/constant.rs | 2 +- src/librustc_codegen_ssa/mir/mod.rs | 12 +++++----- src/librustc_codegen_ssa/mir/operand.rs | 6 ++--- src/librustc_codegen_ssa/mir/place.rs | 6 ++--- src/librustc_codegen_ssa/mir/rvalue.rs | 8 +++---- src/librustc_codegen_ssa/mir/statement.rs | 2 +- src/librustc_codegen_ssa/mono_item.rs | 4 ++-- src/librustc_codegen_ssa/traits/backend.rs | 2 +- src/librustc_codegen_ssa/traits/builder.rs | 2 +- src/librustc_driver/pretty.rs | 2 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/types.rs | 2 +- src/librustc_metadata/creader.rs | 2 +- src/librustc_metadata/decoder.rs | 6 ++--- src/librustc_mir/borrow_check/borrow_set.rs | 2 +- src/librustc_mir/borrow_check/flows.rs | 2 +- src/librustc_mir/borrow_check/mod.rs | 6 ++--- .../borrow_check/nll/constraint_generation.rs | 2 +- .../borrow_check/nll/explain_borrow/find_use.rs | 4 ++-- src/librustc_mir/borrow_check/nll/invalidation.rs | 2 +- .../borrow_check/nll/region_infer/graphviz.rs | 4 ++-- .../nll/type_check/constraint_conversion.rs | 2 +- .../nll/type_check/free_region_relations.rs | 2 +- .../borrow_check/nll/type_check/liveness/trace.rs | 12 +++++----- .../borrow_check/nll/type_check/mod.rs | 6 ++--- .../borrow_check/nll/type_check/relate_tys.rs | 2 +- .../borrow_check/nll/universal_regions.rs | 2 +- src/librustc_mir/borrow_check/prefixes.rs | 2 +- src/librustc_mir/borrow_check/used_muts.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 6 ++--- src/librustc_mir/build/mod.rs | 2 +- src/librustc_mir/dataflow/impls/borrowed_locals.rs | 6 ++--- src/librustc_mir/dataflow/impls/borrows.rs | 2 +- src/librustc_mir/dataflow/impls/mod.rs | 14 ++++++------ .../dataflow/impls/storage_liveness.rs | 4 ++-- src/librustc_mir/dataflow/mod.rs | 22 +++++++++--------- src/librustc_mir/dataflow/move_paths/builder.rs | 4 ++-- src/librustc_mir/hair/cx/mod.rs | 2 +- src/librustc_mir/hair/cx/to_ref.rs | 12 +++++----- src/librustc_mir/hair/pattern/_match.rs | 26 +++++++++++----------- src/librustc_mir/hair/pattern/check_match.rs | 8 +++---- src/librustc_mir/hair/pattern/mod.rs | 2 +- src/librustc_mir/interpret/eval_context.rs | 4 ++-- src/librustc_mir/interpret/snapshot.rs | 2 +- src/librustc_mir/interpret/visitor.rs | 2 +- src/librustc_mir/monomorphize/collector.rs | 4 ++-- src/librustc_mir/monomorphize/partitioning.rs | 4 ++-- src/librustc_mir/shim.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 2 +- src/librustc_mir/transform/elaborate_drops.rs | 4 ++-- src/librustc_mir/transform/generator.rs | 6 ++--- src/librustc_mir/transform/inline.rs | 2 +- src/librustc_mir/transform/mod.rs | 2 +- src/librustc_mir/transform/promote_consts.rs | 2 +- src/librustc_mir/transform/simplify.rs | 4 ++-- .../transform/uniform_array_move_out.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 4 ++-- src/librustc_passes/loops.rs | 2 +- src/librustc_passes/rvalue_promotion.rs | 2 +- src/librustc_privacy/lib.rs | 10 ++++----- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustc_resolve/check_unused.rs | 2 +- src/librustc_resolve/diagnostics.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_resolve/macros.rs | 2 +- src/librustc_resolve/resolve_imports.rs | 10 ++++----- src/librustc_save_analysis/dump_visitor.rs | 6 ++--- src/librustc_save_analysis/lib.rs | 6 ++--- src/librustc_traits/chalk_context/mod.rs | 2 +- src/librustc_traits/chalk_context/resolvent_ops.rs | 2 +- src/librustc_traits/chalk_context/unify.rs | 2 +- src/librustc_traits/type_op.rs | 2 +- src/librustc_typeck/check/autoderef.rs | 2 +- src/librustc_typeck/check/generator_interior.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 8 +++---- src/librustc_typeck/check/writeback.rs | 4 ++-- src/librustc_typeck/check_unused.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- src/librustc_typeck/outlives/implicit_infer.rs | 2 +- src/librustc_typeck/variance/constraints.rs | 2 +- src/librustc_typeck/variance/solve.rs | 2 +- src/librustc_typeck/variance/terms.rs | 2 +- src/librustdoc/passes/check_code_block_syntax.rs | 2 +- src/librustdoc/test.rs | 2 +- src/libserialize/json.rs | 2 +- src/libsyntax/ext/expand.rs | 4 ++-- src/libsyntax/ext/placeholders.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 4 ++-- src/libsyntax_ext/deriving/generic/mod.rs | 2 +- src/libsyntax_ext/format.rs | 2 +- 154 files changed, 305 insertions(+), 305 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 85602320f0b..213e57a3b37 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -7,7 +7,7 @@ use crate::ty::{self, TyCtxt}; use crate::hir::{self, PatKind}; use crate::hir::def_id::DefId; -struct CFGBuilder<'a, 'tcx: 'a> { +struct CFGBuilder<'a, 'tcx> { tcx: TyCtxt<'tcx>, owner_def_id: DefId, tables: &'a ty::TypeckTables<'tcx>, diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs index 66963e5856e..918120057d4 100644 --- a/src/librustc/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -11,7 +11,7 @@ use crate::ty::TyCtxt; pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode); pub type Edge<'a> = &'a cfg::CFGEdge; -pub struct LabelledCFG<'a, 'tcx: 'a> { +pub struct LabelledCFG<'a, 'tcx> { pub tcx: TyCtxt<'tcx>, pub cfg: &'a cfg::CFG, pub name: String, diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index f7647167a75..e8f83093bda 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -207,8 +207,8 @@ macro_rules! define_dep_nodes { pub fn new<'a, 'tcx>(tcx: TyCtxt<'tcx>, dep: DepConstructor<'tcx>) -> DepNode - where 'tcx: 'a, - 'tcx: 'a + where 'tcx, + 'tcx { match dep { $( diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 666cfc3f6dc..e29a373ec3b 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -74,7 +74,7 @@ impl<'a> FnKind<'a> { /// /// See the comments on `ItemLikeVisitor` for more details on the overall /// visit strategy. -pub enum NestedVisitorMap<'this, 'tcx: 'this> { +pub enum NestedVisitorMap<'this, 'tcx> { /// Do not visit any nested things. When you add a new /// "non-nested" thing, you will want to audit such uses to see if /// they remain valid. diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 5a548ce8d9f..153397f11b5 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -415,7 +415,7 @@ impl<'a> LoweringContext<'a> { /// needed from arbitrary locations in the crate, /// e.g., the number of lifetime generic parameters /// declared for every type and trait definition. - struct MiscCollector<'tcx, 'interner: 'tcx> { + struct MiscCollector<'tcx, 'interner> { lctx: &'tcx mut LoweringContext<'interner>, hir_id_owner: Option, } @@ -561,7 +561,7 @@ impl<'a> LoweringContext<'a> { } } - struct ItemLowerer<'tcx, 'interner: 'tcx> { + struct ItemLowerer<'tcx, 'interner> { lctx: &'tcx mut LoweringContext<'interner>, } @@ -1788,7 +1788,7 @@ impl<'a> LoweringContext<'a> { // This visitor walks over `impl Trait` bounds and creates defs for all lifetimes that // appear in the bounds, excluding lifetimes that are created within the bounds. // E.g., `'a`, `'b`, but not `'c` in `impl for<'c> SomeTrait<'a, 'b, 'c>`. - struct ImplTraitLifetimeCollector<'r, 'a: 'r> { + struct ImplTraitLifetimeCollector<'r, 'a> { context: &'r mut LoweringContext<'a>, parent: DefIndex, exist_ty_id: NodeId, @@ -1799,7 +1799,7 @@ impl<'a> LoweringContext<'a> { output_lifetime_params: Vec, } - impl<'r, 'a: 'r, 'v> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a> { + impl<'r, 'a, 'v> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a> { fn nested_visit_map<'this>( &'this mut self, ) -> hir::intravisit::NestedVisitorMap<'this, 'v> { diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 32d0e069f72..60465c04ec6 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -26,19 +26,19 @@ pub fn check_crate<'hir>(hir_map: &hir::map::Map<'hir>) { } } -struct HirIdValidator<'a, 'hir: 'a> { +struct HirIdValidator<'a, 'hir> { hir_map: &'a hir::map::Map<'hir>, owner_def_index: Option, hir_ids_seen: FxHashSet, errors: &'a Lock>, } -struct OuterVisitor<'a, 'hir: 'a> { +struct OuterVisitor<'a, 'hir> { hir_map: &'a hir::map::Map<'hir>, errors: &'a Lock>, } -impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> { +impl<'a, 'hir> OuterVisitor<'a, 'hir> { fn new_inner_visitor(&self, hir_map: &'a hir::map::Map<'hir>) -> HirIdValidator<'a, 'hir> { @@ -51,7 +51,7 @@ impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> { } } -impl<'a, 'hir: 'a> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> { +impl<'a, 'hir> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> { fn visit_item(&mut self, i: &'hir hir::Item) { let mut inner_visitor = self.new_inner_visitor(self.hir_map); inner_visitor.check(i.hir_id, |this| intravisit::walk_item(this, i)); @@ -68,7 +68,7 @@ impl<'a, 'hir: 'a> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> { } } -impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> { +impl<'a, 'hir> HirIdValidator<'a, 'hir> { #[cold] #[inline(never)] fn error(&self, f: impl FnOnce() -> String) { @@ -133,7 +133,7 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> { } } -impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { +impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'hir> { diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 0bb939889a8..e4aec59c1f6 100644 --- a/src/librustc/infer/at.rs +++ b/src/librustc/infer/at.rs @@ -30,13 +30,13 @@ use super::*; use crate::ty::Const; use crate::ty::relate::{Relate, TypeRelation}; -pub struct At<'a, 'tcx: 'a> { +pub struct At<'a, 'tcx> { pub infcx: &'a InferCtxt<'a, 'tcx>, pub cause: &'a ObligationCause<'tcx>, pub param_env: ty::ParamEnv<'tcx>, } -pub struct Trace<'a, 'tcx: 'a> { +pub struct Trace<'a, 'tcx> { at: At<'a, 'tcx>, a_is_expected: bool, trace: TypeTrace<'tcx>, diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index b4779eec65f..383048b5fe7 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -275,7 +275,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic { } } -struct Canonicalizer<'cx, 'tcx: 'cx> { +struct Canonicalizer<'cx, 'tcx> { infcx: Option<&'cx InferCtxt<'cx, 'tcx>>, tcx: TyCtxt<'tcx>, variables: SmallVec<[CanonicalVarInfo; 8]>, diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index 23550569f7c..e20b53455f4 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -44,7 +44,7 @@ use syntax::ast; use syntax_pos::{Span, DUMMY_SP}; #[derive(Clone)] -pub struct CombineFields<'infcx, 'tcx: 'infcx> { +pub struct CombineFields<'infcx, 'tcx> { pub infcx: &'infcx InferCtxt<'infcx, 'tcx>, pub trace: TypeTrace<'tcx>, pub cause: Option, @@ -355,7 +355,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> { } } -struct Generalizer<'cx, 'tcx: 'cx> { +struct Generalizer<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, /// The span, used when creating new type variables and things. diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index 39d8241e6b4..5eebe9e78d3 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -11,7 +11,7 @@ use crate::mir::interpret::ConstValue; use crate::infer::unify_key::replace_if_possible; /// Ensures `a` is made equal to `b`. Returns `a` on success. -pub struct Equate<'combine, 'infcx: 'combine, 'tcx: 'infcx> { +pub struct Equate<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } diff --git a/src/librustc/infer/error_reporting/nice_region_error/mod.rs b/src/librustc/infer/error_reporting/nice_region_error/mod.rs index 541d9a96dbe..1edb1c601bf 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/mod.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/mod.rs @@ -30,7 +30,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { } } -pub struct NiceRegionError<'cx, 'tcx: 'cx> { +pub struct NiceRegionError<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, error: Option>, regions: Option<(Span, ty::Region<'tcx>, ty::Region<'tcx>)>, diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 645f2b02338..7f4a817faf1 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -41,7 +41,7 @@ use std::collections::hash_map::Entry; use super::InferCtxt; use super::unify_key::ToType; -pub struct TypeFreshener<'a, 'tcx: 'a> { +pub struct TypeFreshener<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, ty_freshen_count: u32, const_freshen_count: u32, diff --git a/src/librustc/infer/fudge.rs b/src/librustc/infer/fudge.rs index 59364862c64..658a9c1d888 100644 --- a/src/librustc/infer/fudge.rs +++ b/src/librustc/infer/fudge.rs @@ -133,7 +133,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } } -pub struct InferenceFudger<'a, 'tcx: 'a> { +pub struct InferenceFudger<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, type_vars: (Range, Vec), int_vars: Range, diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index 7f184d3424f..55021316747 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -8,7 +8,7 @@ use crate::ty::{self, Ty, TyCtxt}; use crate::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Greatest lower bound" (common subtype) -pub struct Glb<'combine, 'infcx: 'combine, 'tcx: 'infcx> { +pub struct Glb<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index c7766636e04..a3372f50379 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -27,7 +27,7 @@ use crate::ty::TyVar; use crate::ty::{self, Ty}; use crate::ty::relate::{RelateResult, TypeRelation}; -pub trait LatticeDir<'f, 'tcx: 'f>: TypeRelation<'tcx> { +pub trait LatticeDir<'f, 'tcx>: TypeRelation<'tcx> { fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>; fn cause(&self) -> &ObligationCause<'tcx>; @@ -48,7 +48,7 @@ pub fn super_lattice_tys<'a, 'tcx, L>( ) -> RelateResult<'tcx, Ty<'tcx>> where L: LatticeDir<'a, 'tcx>, - 'tcx: 'a, + 'tcx, { debug!("{}.lattice_tys({:?}, {:?})", this.tag(), diff --git a/src/librustc/infer/lexical_region_resolve/graphviz.rs b/src/librustc/infer/lexical_region_resolve/graphviz.rs index aa4bbcad6d5..ad481417d5e 100644 --- a/src/librustc/infer/lexical_region_resolve/graphviz.rs +++ b/src/librustc/infer/lexical_region_resolve/graphviz.rs @@ -107,7 +107,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>( } } -struct ConstraintGraph<'a, 'tcx: 'a> { +struct ConstraintGraph<'a, 'tcx> { graph_name: String, region_rels: &'a RegionRelations<'a, 'tcx>, map: &'a BTreeMap, SubregionOrigin<'tcx>>, diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 16f5a9d3b36..2613f4c7c2a 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -93,7 +93,7 @@ struct RegionAndOrigin<'tcx> { type RegionGraph<'tcx> = Graph<(), Constraint<'tcx>>; -struct LexicalResolver<'cx, 'tcx: 'cx> { +struct LexicalResolver<'cx, 'tcx> { region_rels: &'cx RegionRelations<'cx, 'tcx>, var_infos: VarInfos, data: RegionConstraintData<'tcx>, diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index 2a9f5856eb8..156288b9e6a 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -8,7 +8,7 @@ use crate::ty::{self, Ty, TyCtxt}; use crate::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Least upper bound" (common supertype) -pub struct Lub<'combine, 'infcx: 'combine, 'tcx: 'infcx> { +pub struct Lub<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 47a276b2bcc..fc46fe383c9 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -585,7 +585,7 @@ impl<'tcx> InferOk<'tcx, ()> { } #[must_use = "once you start a snapshot, you should always consume it"] -pub struct CombinedSnapshot<'a, 'tcx: 'a> { +pub struct CombinedSnapshot<'a, 'tcx> { projection_cache_snapshot: traits::ProjectionCacheSnapshot, type_snapshot: type_variable::Snapshot<'tcx>, const_snapshot: ut::Snapshot>>, diff --git a/src/librustc/infer/nll_relate/mod.rs b/src/librustc/infer/nll_relate/mod.rs index 2c821d0ae15..21489965b1b 100644 --- a/src/librustc/infer/nll_relate/mod.rs +++ b/src/librustc/infer/nll_relate/mod.rs @@ -38,7 +38,7 @@ pub enum NormalizationStrategy { Eager, } -pub struct TypeRelating<'me, 'tcx: 'me, D> +pub struct TypeRelating<'me, 'tcx, D> where D: TypeRelatingDelegate<'tcx>, { @@ -741,7 +741,7 @@ where /// binder depth, and finds late-bound regions targeting the /// `for<..`>. For each of those, it creates an entry in /// `bound_region_scope`. -struct ScopeInstantiator<'me, 'tcx: 'me> { +struct ScopeInstantiator<'me, 'tcx> { next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>, // The debruijn index of the scope we are instantiating. target_index: ty::DebruijnIndex, @@ -798,7 +798,7 @@ impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> { /// scopes. /// /// [blog post]: https://is.gd/0hKvIr -struct TypeGeneralizer<'me, 'tcx: 'me, D> +struct TypeGeneralizer<'me, 'tcx, D> where D: TypeRelatingDelegate<'tcx> + 'me, { diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 328ace51a58..c164f5446fd 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -723,7 +723,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { } } -struct Instantiator<'a, 'tcx: 'a> { +struct Instantiator<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, parent_def_id: DefId, body_id: hir::HirId, diff --git a/src/librustc/infer/outlives/env.rs b/src/librustc/infer/outlives/env.rs index 4b5df444148..d5558861285 100644 --- a/src/librustc/infer/outlives/env.rs +++ b/src/librustc/infer/outlives/env.rs @@ -67,7 +67,7 @@ pub struct OutlivesEnvironment<'tcx> { /// because of implied bounds. pub type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>; -impl<'a, 'tcx: 'a> OutlivesEnvironment<'tcx> { +impl<'a, 'tcx> OutlivesEnvironment<'tcx> { pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self { let mut env = OutlivesEnvironment { param_env, diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index 671718b1008..0ae4446ee63 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -226,7 +226,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> { /// via a "delegate" of type `D` -- this is usually the `infcx`, which /// accrues them into the `region_obligations` code, but for NLL we /// use something else. -pub struct TypeOutlives<'cx, 'tcx: 'cx, D> +pub struct TypeOutlives<'cx, 'tcx, D> where D: TypeOutlivesDelegate<'tcx>, { diff --git a/src/librustc/infer/outlives/verify.rs b/src/librustc/infer/outlives/verify.rs index 96335e1052e..f23e52fcfe4 100644 --- a/src/librustc/infer/outlives/verify.rs +++ b/src/librustc/infer/outlives/verify.rs @@ -12,7 +12,7 @@ use crate::util::captures::Captures; /// via a "delegate" of type `D` -- this is usually the `infcx`, which /// accrues them into the `region_obligations` code, but for NLL we /// use something else. -pub struct VerifyBoundCx<'cx, 'tcx: 'cx> { +pub struct VerifyBoundCx<'cx, 'tcx> { tcx: TyCtxt<'tcx>, region_bound_pairs: &'cx RegionBoundPairs<'tcx>, implicit_region_bound: Option>, diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index 810c64185a7..7e553d7666b 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -12,7 +12,7 @@ use crate::ty::fold::{TypeFolder, TypeVisitor}; /// been unified with (similar to `shallow_resolve`, but deep). This is /// useful for printing messages etc but also required at various /// points for correctness. -pub struct OpportunisticVarResolver<'a, 'tcx: 'a> { +pub struct OpportunisticVarResolver<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, } @@ -50,7 +50,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> { /// The opportunistic type and region resolver is similar to the /// opportunistic type resolver, but also opportunistically resolves /// regions. It is useful for canonicalization. -pub struct OpportunisticTypeAndRegionResolver<'a, 'tcx: 'a> { +pub struct OpportunisticTypeAndRegionResolver<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, } @@ -101,7 +101,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticTypeAndRegionResolver<'a, 'tcx> /// type variables that don't yet have a value. The first unresolved type is stored. /// It does not construct the fully resolved type (which might /// involve some hashing and so forth). -pub struct UnresolvedTypeFinder<'a, 'tcx: 'a> { +pub struct UnresolvedTypeFinder<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, /// Used to find the type parameter name and location for error reporting. @@ -171,7 +171,7 @@ where // N.B. This type is not public because the protocol around checking the // `err` field is not enforcable otherwise. -struct FullTypeResolver<'a, 'tcx: 'a> { +struct FullTypeResolver<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, err: Option>, } diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index ed84e3f63ae..1452a6dee5b 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -11,7 +11,7 @@ use crate::mir::interpret::ConstValue; use std::mem; /// Ensures `a` is made a subtype of `b`. Returns `a` on success. -pub struct Sub<'combine, 'infcx: 'combine, 'tcx: 'infcx> { +pub struct Sub<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index e90f4ca94c6..7f09120bbdd 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -507,7 +507,7 @@ impl LintStore { } /// Context for lint checking after type checking. -pub struct LateContext<'a, 'tcx: 'a> { +pub struct LateContext<'a, 'tcx> { /// Type context we're checking in. pub tcx: TyCtxt<'tcx>, @@ -533,7 +533,7 @@ pub struct LateContext<'a, 'tcx: 'a> { only_module: bool, } -pub struct LateContextAndPass<'a, 'tcx: 'a, T: LateLintPass<'a, 'tcx>> { +pub struct LateContextAndPass<'a, 'tcx, T: LateLintPass<'a, 'tcx>> { context: LateContext<'a, 'tcx>, pass: T, } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 63503f58156..9e2038fa89e 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -38,7 +38,7 @@ fn should_explore<'tcx>(tcx: TyCtxt<'tcx>, hir_id: hir::HirId) -> bool { } } -struct MarkSymbolVisitor<'a, 'tcx: 'a> { +struct MarkSymbolVisitor<'a, 'tcx> { worklist: Vec, tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, @@ -351,7 +351,7 @@ fn has_allow_dead_code_or_lang_attr( // or // 2) We are not sure to be live or not // * Implementation of a trait method -struct LifeSeeder<'k, 'tcx: 'k> { +struct LifeSeeder<'k, 'tcx> { worklist: Vec, krate: &'k hir::Crate, tcx: TyCtxt<'tcx>, diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index d9e7caebb98..d1867e8fa36 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -11,7 +11,7 @@ use crate::hir::itemlikevisit::ItemLikeVisitor; use crate::ty::TyCtxt; use crate::ty::query::Providers; -struct EntryContext<'a, 'tcx: 'a> { +struct EntryContext<'a, 'tcx> { session: &'a Session, map: &'a hir_map::Map<'tcx>, diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 61770e6f487..1c3eead90fa 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -229,7 +229,7 @@ impl OverloadedCallType { // The ExprUseVisitor type // // This is the code that actually walks the tree. -pub struct ExprUseVisitor<'a, 'tcx: 'a> { +pub struct ExprUseVisitor<'a, 'tcx> { mc: mc::MemCategorizationContext<'a, 'tcx>, delegate: &'a mut dyn Delegate<'tcx>, param_env: ty::ParamEnv<'tcx>, diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index a8a7df08469..60e41f7eb0f 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -15,7 +15,7 @@ use crate::ty::{self, TyCtxt, Region}; /// /// This stuff is a bit convoluted and should be refactored, but as we /// transition to NLL, it'll all go away anyhow. -pub struct RegionRelations<'a, 'tcx: 'a> { +pub struct RegionRelations<'a, 'tcx> { pub tcx: TyCtxt<'tcx>, /// The context used to fetch the region maps. diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 3d2bc6c7bf8..36411f81f1a 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -352,7 +352,7 @@ impl IrMaps<'tcx> { } } -fn visit_fn<'a, 'tcx: 'a>( +fn visit_fn<'a, 'tcx>( ir: &mut IrMaps<'tcx>, fk: FnKind<'tcx>, decl: &'tcx hir::FnDecl, @@ -682,7 +682,7 @@ const ACC_READ: u32 = 1; const ACC_WRITE: u32 = 2; const ACC_USE: u32 = 4; -struct Liveness<'a, 'tcx: 'a> { +struct Liveness<'a, 'tcx> { ir: &'a mut IrMaps<'tcx>, tables: &'a ty::TypeckTables<'tcx>, s: Specials, diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 628a44cbfe0..593c5e73421 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -65,7 +65,7 @@ fn method_might_be_inlined<'tcx>( } // Information needed while computing reachability. -struct ReachableContext<'a, 'tcx: 'a> { +struct ReachableContext<'a, 'tcx> { // The type context. tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, @@ -334,13 +334,13 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { // items of non-exported traits (or maybe all local traits?) unless their respective // trait items are used from inlinable code through method call syntax or UFCS, or their // trait is a lang item. -struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> { +struct CollectPrivateImplItemsVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, access_levels: &'a privacy::AccessLevels, worklist: &'a mut Vec, } -impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx> { +impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { // Anything which has custom linkage gets thrown on the worklist no // matter where it is in the crate, along with "special std symbols" diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 76bff500634..f68e18c2bb8 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -217,7 +217,7 @@ impl_stable_hash_for!(struct crate::middle::resolve_lifetime::ResolveLifetimes { object_lifetime_defaults }); -struct LifetimeContext<'a, 'tcx: 'a> { +struct LifetimeContext<'a, 'tcx> { tcx: TyCtxt<'tcx>, map: &'a mut NamedRegionMap, scope: ScopeRef<'a>, @@ -1160,7 +1160,7 @@ fn signal_shadowing_problem(tcx: TyCtxt<'_>, name: ast::Name, orig: Original, sh // Adds all labels in `b` to `ctxt.labels_in_fn`, signalling a warning // if one of the label shadows a lifetime or another label. fn extract_labels(ctxt: &mut LifetimeContext<'_, '_>, body: &hir::Body) { - struct GatherLabels<'a, 'tcx: 'a> { + struct GatherLabels<'a, 'tcx> { tcx: TyCtxt<'tcx>, scope: ScopeRef<'a>, labels_in_fn: &'a mut Vec, diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 19d127a565f..5a1e5212f86 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -105,7 +105,7 @@ impl_stable_hash_for!(struct self::Index<'tcx> { }); // A private tree-walker for producing an Index. -struct Annotator<'a, 'tcx: 'a> { +struct Annotator<'a, 'tcx> { tcx: TyCtxt<'tcx>, index: &'a mut Index<'tcx>, parent_stab: Option<&'tcx Stability>, @@ -113,7 +113,7 @@ struct Annotator<'a, 'tcx: 'a> { in_trait_impl: bool, } -impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { +impl<'a, 'tcx> Annotator<'a, 'tcx> { // Determine the stability for a node based on its attributes and inherited // stability. The stability is recorded in the index and used as the parent. fn annotate(&mut self, hir_id: HirId, attrs: &[Attribute], @@ -316,12 +316,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { } } -struct MissingStabilityAnnotations<'a, 'tcx: 'a> { +struct MissingStabilityAnnotations<'a, 'tcx> { tcx: TyCtxt<'tcx>, access_levels: &'a AccessLevels, } -impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> { +impl<'a, 'tcx> MissingStabilityAnnotations<'a, 'tcx> { fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) { let stab = self.tcx.stability().local_stability(hir_id); let is_error = !self.tcx.sess.opts.test && diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 422ff3f2fd3..b6cd24c291a 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -17,7 +17,7 @@ use crate::ty::TyCtxt; macro_rules! weak_lang_items { ($($name:ident, $item:ident, $sym:ident;)*) => ( -struct Context<'a, 'tcx: 'a> { +struct Context<'a, 'tcx> { tcx: TyCtxt<'tcx>, items: &'a mut lang_items::LanguageItems, } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 1d5c1cb927d..9dfd8d959a3 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2104,7 +2104,7 @@ impl<'tcx> Place<'tcx> { /// N.B., this particular impl strategy is not the most obvious. It was /// chosen because it makes a measurable difference to NLL /// performance, as this code (`borrow_conflicts_with_place`) is somewhat hot. -pub enum Projections<'p, 'tcx: 'p> { +pub enum Projections<'p, 'tcx> { Empty, List { @@ -2143,7 +2143,7 @@ impl<'p, 'tcx> IntoIterator for &'p Projections<'p, 'tcx> { /// N.B., this is not a *true* Rust iterator -- the code above just /// manually invokes `next`. This is because we (sometimes) want to /// keep executing even after `None` has been returned. -pub struct ProjectionsIter<'p, 'tcx: 'p> { +pub struct ProjectionsIter<'p, 'tcx> { pub value: &'p Projections<'p, 'tcx>, } diff --git a/src/librustc/mir/traversal.rs b/src/librustc/mir/traversal.rs index 77af0e6661b..1416a5f0a6e 100644 --- a/src/librustc/mir/traversal.rs +++ b/src/librustc/mir/traversal.rs @@ -20,7 +20,7 @@ use super::*; /// /// A preorder traversal of this graph is either `A B D C` or `A C D B` #[derive(Clone)] -pub struct Preorder<'a, 'tcx: 'a> { +pub struct Preorder<'a, 'tcx> { body: &'a Body<'tcx>, visited: BitSet, worklist: Vec, @@ -98,7 +98,7 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> { /// ``` /// /// A Postorder traversal of this graph is `D B C A` or `D C B A` -pub struct Postorder<'a, 'tcx: 'a> { +pub struct Postorder<'a, 'tcx> { body: &'a Body<'tcx>, visited: BitSet, visit_stack: Vec<(BasicBlock, Successors<'a>)>, @@ -251,7 +251,7 @@ impl<'a, 'tcx> Iterator for Postorder<'a, 'tcx> { /// constructed as few times as possible. Use the `reset` method to be able /// to re-use the traversal #[derive(Clone)] -pub struct ReversePostorder<'a, 'tcx: 'a> { +pub struct ReversePostorder<'a, 'tcx> { body: &'a Body<'tcx>, blocks: Vec, idx: usize diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index dcf69fee0e1..4b65d3b9d8e 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1449,7 +1449,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { param_env: ty::ParamEnv<'tcx>, pred: ty::PolyTraitRef<'tcx>, ) -> bool { - struct ParamToVarFolder<'a, 'tcx: 'a> { + struct ParamToVarFolder<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, var_map: FxHashMap, Ty<'tcx>>, } diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 5e2c949c7d8..f106458c767 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -224,7 +224,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> { } } -struct FulfillProcessor<'a, 'b: 'a, 'tcx: 'b> { +struct FulfillProcessor<'a, 'b, 'tcx> { selcx: &'a mut SelectionContext<'b, 'tcx>, register_region_obligations: bool, } diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index d189bb23116..04364cd6311 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -285,7 +285,7 @@ where } } -struct AssocTypeNormalizer<'a, 'b: 'a, 'tcx: 'b> { +struct AssocTypeNormalizer<'a, 'b, 'tcx> { selcx: &'a mut SelectionContext<'b, 'tcx>, param_env: ty::ParamEnv<'tcx>, cause: ObligationCause<'tcx>, diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index 50476721e82..a45213b06d3 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -73,7 +73,7 @@ pub struct NormalizationResult<'tcx> { pub normalized_ty: Ty<'tcx>, } -struct QueryNormalizer<'cx, 'tcx: 'cx> { +struct QueryNormalizer<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, cause: &'cx ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 5aa7a120957..c698b0c2933 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -50,7 +50,7 @@ use std::iter; use std::rc::Rc; use crate::util::nodemap::{FxHashMap, FxHashSet}; -pub struct SelectionContext<'cx, 'tcx: 'cx> { +pub struct SelectionContext<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, /// Freshener used specifically for entries on the obligation @@ -144,7 +144,7 @@ impl IntercrateAmbiguityCause { } // A stack that walks back up the stack frame. -struct TraitObligationStack<'prev, 'tcx: 'prev> { +struct TraitObligationStack<'prev, 'tcx> { obligation: &'prev TraitObligation<'tcx>, /// Trait ref from `obligation` but "freshened" with the @@ -697,7 +697,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) -> Result where I: IntoIterator>, - 'tcx: 'a, + 'tcx, { let mut result = EvaluatedToOk; for obligation in predicates { @@ -3789,7 +3789,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { matcher.relate(previous, current).is_ok() } - fn push_stack<'o, 's: 'o>( + fn push_stack<'o, 's>( &mut self, previous_stack: TraitObligationStackList<'s, 'tcx>, obligation: &'o TraitObligation<'tcx>, @@ -4252,7 +4252,7 @@ impl<'tcx> ProvisionalEvaluationCache<'tcx> { } #[derive(Copy, Clone)] -struct TraitObligationStackList<'o, 'tcx: 'o> { +struct TraitObligationStackList<'o, 'tcx> { cache: &'o ProvisionalEvaluationCache<'tcx>, head: Option<&'o TraitObligationStack<'o, 'tcx>>, } diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 6f83991a2da..5781f40b93a 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -511,7 +511,7 @@ fn decode_tagged<'a, 'tcx, D, T, V>(decoder: &mut D, where T: Decodable + Eq + ::std::fmt::Debug, V: Decodable, D: DecoderWithPosition, - 'tcx: 'a, + 'tcx, { let start_pos = decoder.position(); diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 48e68167f82..0f158d2982a 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -89,7 +89,7 @@ macro_rules! profq_query_msg { /// A type representing the responsibility to execute the job in the `job` field. /// This will poison the relevant query if dropped. -pub(super) struct JobOwner<'a, 'tcx: 'a, Q: QueryDescription<'tcx> + 'a> { +pub(super) struct JobOwner<'a, 'tcx, Q: QueryDescription<'tcx> + 'a> { cache: &'a Lock>, key: Q::Key, job: Lrc>, @@ -230,7 +230,7 @@ pub struct CycleError<'tcx> { } /// The result of `try_get_lock` -pub(super) enum TryGetJob<'a, 'tcx: 'a, D: QueryDescription<'tcx> + 'a> { +pub(super) enum TryGetJob<'a, 'tcx, D: QueryDescription<'tcx> + 'a> { /// The query is not yet started. Contains a guard to the cache eventually used to start it. NotYetStarted(JobOwner<'a, 'tcx, D>), diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 6b2f00e5f70..1979b4317a7 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -101,7 +101,7 @@ pub fn predicate_obligations<'a, 'tcx>( wf.normalize() } -struct WfPredicates<'a, 'tcx: 'a> { +struct WfPredicates<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, body_id: hir::HirId, diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 54989db46c1..ace44421d37 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -78,7 +78,7 @@ fn owned_ptr_base_path_rc<'tcx>(loan_path: &Rc>) -> Rc { +struct CheckLoanCtxt<'a, 'tcx> { bccx: &'a BorrowckCtxt<'a, 'tcx>, dfcx_loans: &'a LoanDataFlow<'tcx>, move_data: &'a move_data::FlowedMoveData<'tcx>, diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 4d03b58179d..cc1f7232e04 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -16,7 +16,7 @@ use rustc::hir::*; use rustc::hir::Node; use log::debug; -struct GatherMoveInfo<'c, 'tcx: 'c> { +struct GatherMoveInfo<'c, 'tcx> { id: hir::ItemLocalId, kind: MoveKind, cmt: &'c mc::cmt_<'tcx>, @@ -91,7 +91,7 @@ pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, gather_move(bccx, move_data, move_error_collector, move_info); } -pub fn gather_move_from_pat<'a, 'c, 'tcx: 'c>(bccx: &BorrowckCtxt<'a, 'tcx>, +pub fn gather_move_from_pat<'a, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_data: &MoveData<'tcx>, move_error_collector: &mut MoveErrorCollector<'tcx>, move_pat: &hir::Pat, @@ -121,7 +121,7 @@ pub fn gather_move_from_pat<'a, 'c, 'tcx: 'c>(bccx: &BorrowckCtxt<'a, 'tcx>, gather_move(bccx, move_data, move_error_collector, move_info); } -fn gather_move<'a, 'c, 'tcx: 'c>(bccx: &BorrowckCtxt<'a, 'tcx>, +fn gather_move<'a, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_data: &MoveData<'tcx>, move_error_collector: &mut MoveErrorCollector<'tcx>, move_info: GatherMoveInfo<'c, 'tcx>) { diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 1607a629201..3122a6060fb 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -38,7 +38,7 @@ pub fn guarantee_lifetime<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, /////////////////////////////////////////////////////////////////////////// // Private -struct GuaranteeLifetimeContext<'a, 'tcx: 'a> { +struct GuaranteeLifetimeContext<'a, 'tcx> { bccx: &'a BorrowckCtxt<'a, 'tcx>, // the scope of the function body for the enclosing item diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index b1854a06693..887011d3476 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -56,7 +56,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, (all_loans, move_data) } -struct GatherLoanCtxt<'a, 'tcx: 'a> { +struct GatherLoanCtxt<'a, 'tcx> { bccx: &'a BorrowckCtxt<'a, 'tcx>, move_data: move_data::MoveData<'tcx>, move_error_collector: move_error::MoveErrorCollector<'tcx>, diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index 9f4c05a6b25..371e6c55a73 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -37,7 +37,7 @@ pub fn compute_restrictions<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, /////////////////////////////////////////////////////////////////////////// // Private -struct RestrictionsContext<'a, 'tcx: 'a> { +struct RestrictionsContext<'a, 'tcx> { bccx: &'a BorrowckCtxt<'a, 'tcx>, span: Span, loan_region: ty::Region<'tcx>, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 93cea6d2f01..025d5adc2b3 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -552,7 +552,7 @@ pub enum bckerr_code<'tcx> { // Combination of an error code and the categorization of the expression // that caused it #[derive(Debug, PartialEq)] -pub struct BckError<'c, 'tcx: 'c> { +pub struct BckError<'c, 'tcx> { span: Span, cause: AliasableViolationKind, cmt: &'c mc::cmt_<'tcx>, diff --git a/src/librustc_borrowck/graphviz.rs b/src/librustc_borrowck/graphviz.rs index 1f248066695..7a8a23ca76a 100644 --- a/src/librustc_borrowck/graphviz.rs +++ b/src/librustc_borrowck/graphviz.rs @@ -30,7 +30,7 @@ impl Variant { } } -pub struct DataflowLabeller<'a, 'tcx: 'a> { +pub struct DataflowLabeller<'a, 'tcx> { pub inner: cfg_dot::LabelledCFG<'a, 'tcx>, pub variants: Vec, pub borrowck_ctxt: &'a BorrowckCtxt<'a, 'tcx>, diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 9102ba91df8..e06b4d8b306 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -27,7 +27,7 @@ use std::iter::TrustedLen; // All Builders must have an llfn associated with them #[must_use] -pub struct Builder<'a, 'll: 'a, 'tcx: 'll> { +pub struct Builder<'a, 'll, 'tcx> { pub llbuilder: &'ll mut llvm::Builder<'ll>, pub cx: &'a CodegenCx<'ll, 'tcx>, } diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 588f7481cc0..6a61b180de4 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -34,7 +34,7 @@ use crate::abi::Abi; /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM /// `llvm::Context` so that several compilation units may be optimized in parallel. /// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`. -pub struct CodegenCx<'ll, 'tcx: 'll> { +pub struct CodegenCx<'ll, 'tcx> { pub tcx: TyCtxt<'tcx>, pub check_overflow: bool, pub use_dll_storage_attrs: bool, diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index a0dd767a3a8..a8a998a4d95 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -125,7 +125,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend { ) { unsafe { allocator::codegen(tcx, mods, kind) } } - fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString) { + fn compile_codegen_unit<'a, 'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString) { base::compile_codegen_unit(tcx, cgu_name); } fn target_machine_factory( diff --git a/src/librustc_codegen_ssa/README.md b/src/librustc_codegen_ssa/README.md index 11fac239edf..c8bb2e7ee99 100644 --- a/src/librustc_codegen_ssa/README.md +++ b/src/librustc_codegen_ssa/README.md @@ -29,11 +29,11 @@ While the LLVM-specific code will be left in `rustc_codegen_llvm`, all the new t The two most important structures for the LLVM codegen are `CodegenCx` and `Builder`. They are parametrized by multiple lifetime parameters and the type for `Value`. ```rust -struct CodegenCx<'ll, 'tcx: 'll> { +struct CodegenCx<'ll, 'tcx> { /* ... */ } -struct Builder<'a, 'll: 'a, 'tcx: 'll> { +struct Builder<'a, 'll, 'tcx> { cx: &'a CodegenCx<'ll, 'tcx>, /* ... */ } @@ -49,7 +49,7 @@ The code in `rustc_codegen_llvm` has to deal with multiple explicit lifetime par Although there are already many lifetime parameters in the code, making it generic uncovered situations where the borrow-checker was passing only due to the special nature of the LLVM objects manipulated (they are extern pointers). For instance, a additional lifetime parameter had to be added to `LocalAnalyser` in `analyse.rs`, leading to the definition: ```rust -struct LocalAnalyzer<'mir, 'a: 'mir, 'tcx: 'a> { +struct LocalAnalyzer<'mir, 'a, 'tcx> { /* ... */ } ``` @@ -61,7 +61,7 @@ However, the two most important structures `CodegenCx` and `Builder` are not def Because they have to be defined by the backend, `CodegenCx` and `Builder` will be the structures implementing all the traits defining the backend's interface. These traits are defined in the folder `rustc_codegen_ssa/traits` and all the backend-agnostic code is parametrized by them. For instance, let us explain how a function in `base.rs` is parametrized: ```rust -pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn codegen_instance<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx, instance: Instance<'tcx> ) { @@ -74,7 +74,7 @@ In this signature, we have the two lifetime parameters explained earlier and the On the trait side, here is an example with part of the definition of `BuilderMethods` in `traits/builder.rs`: ```rust -pub trait BuilderMethods<'a, 'tcx: 'a>: +pub trait BuilderMethods<'a, 'tcx>: HasCodegen<'tcx> + DebugInfoBuilderMethods<'tcx> + ArgTypeMethods<'tcx> diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index ca686453b6d..a06f324d389 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -88,7 +88,7 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate { } } -pub fn compare_simd_types<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, lhs: Bx::Value, rhs: Bx::Value, @@ -152,7 +152,7 @@ pub fn unsized_info<'tcx, Cx: CodegenMethods<'tcx>>( } /// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer. -pub fn unsize_thin_ptr<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn unsize_thin_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, src: Bx::Value, src_ty: Ty<'tcx>, @@ -207,7 +207,7 @@ pub fn unsize_thin_ptr<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( /// Coerce `src`, which is a reference to a value of type `src_ty`, /// to a value of type `dst_ty` and store the result in `dst` -pub fn coerce_unsized_into<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, src: PlaceRef<'tcx, Bx::Value>, dst: PlaceRef<'tcx, Bx::Value> @@ -266,7 +266,7 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( } } -pub fn cast_shift_expr_rhs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn cast_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, op: hir::BinOpKind, lhs: Bx::Value, @@ -275,7 +275,7 @@ pub fn cast_shift_expr_rhs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( cast_shift_rhs(bx, op, lhs, rhs) } -fn cast_shift_rhs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +fn cast_shift_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, op: hir::BinOpKind, lhs: Bx::Value, @@ -316,7 +316,7 @@ pub fn wants_msvc_seh(sess: &Session) -> bool { sess.target.target.options.is_like_msvc } -pub fn from_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn from_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, val: Bx::Value ) -> Bx::Value { @@ -327,7 +327,7 @@ pub fn from_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( } } -pub fn to_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn to_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, val: Bx::Value, layout: layout::TyLayout<'_>, @@ -338,7 +338,7 @@ pub fn to_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( val } -pub fn to_immediate_scalar<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn to_immediate_scalar<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, val: Bx::Value, scalar: &layout::Scalar, @@ -349,7 +349,7 @@ pub fn to_immediate_scalar<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( val } -pub fn memcpy_ty<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn memcpy_ty<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, dst: Bx::Value, dst_align: Align, @@ -366,7 +366,7 @@ pub fn memcpy_ty<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( bx.memcpy(dst, dst_align, src, src_align, bx.cx().const_usize(size), flags); } -pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn codegen_instance<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx, instance: Instance<'tcx>, ) { @@ -387,7 +387,7 @@ pub fn codegen_instance<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( /// Creates the `main` function which will initialize the rust runtime and call /// users main function. -pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx ) { let (main_def_id, span) = match cx.tcx().entry_fn(LOCAL_CRATE) { @@ -412,7 +412,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( None => {} // Do nothing. } - fn create_entry_fn<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( + fn create_entry_fn<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx, sp: Span, rust_main: Bx::Value, diff --git a/src/librustc_codegen_ssa/common.rs b/src/librustc_codegen_ssa/common.rs index e22d4db6dcb..d17edf2ec0a 100644 --- a/src/librustc_codegen_ssa/common.rs +++ b/src/librustc_codegen_ssa/common.rs @@ -137,7 +137,7 @@ pub fn langcall(tcx: TyCtxt<'_>, span: Option, msg: &str, li: LangItem) -> // all shifts). For 32- and 64-bit types, this matches the semantics // of Java. (See related discussion on #1877 and #10183.) -pub fn build_unchecked_lshift<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn build_unchecked_lshift<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, lhs: Bx::Value, rhs: Bx::Value @@ -148,7 +148,7 @@ pub fn build_unchecked_lshift<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( bx.shl(lhs, rhs) } -pub fn build_unchecked_rshift<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn build_unchecked_rshift<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, lhs_t: Ty<'tcx>, lhs: Bx::Value, @@ -165,7 +165,7 @@ pub fn build_unchecked_rshift<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( } } -fn shift_mask_rhs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +fn shift_mask_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, rhs: Bx::Value ) -> Bx::Value { @@ -174,7 +174,7 @@ fn shift_mask_rhs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( bx.and(rhs, shift_val) } -pub fn shift_mask_val<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, llty: Bx::Type, mask_llty: Bx::Type, diff --git a/src/librustc_codegen_ssa/glue.rs b/src/librustc_codegen_ssa/glue.rs index e2b49de05bd..294e2e021d2 100644 --- a/src/librustc_codegen_ssa/glue.rs +++ b/src/librustc_codegen_ssa/glue.rs @@ -7,7 +7,7 @@ use crate::common::IntPredicate; use crate::meth; use crate::traits::*; -pub fn size_and_align_of_dst<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, t: Ty<'tcx>, info: Option diff --git a/src/librustc_codegen_ssa/meth.rs b/src/librustc_codegen_ssa/meth.rs index d38e434d98c..7fe9f5f2513 100644 --- a/src/librustc_codegen_ssa/meth.rs +++ b/src/librustc_codegen_ssa/meth.rs @@ -12,7 +12,7 @@ pub const DESTRUCTOR: VirtualIndex = VirtualIndex(0); pub const SIZE: VirtualIndex = VirtualIndex(1); pub const ALIGN: VirtualIndex = VirtualIndex(2); -impl<'a, 'tcx: 'a> VirtualIndex { +impl<'a, 'tcx> VirtualIndex { pub fn from_index(index: usize) -> Self { VirtualIndex(index as u64 + 3) } diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index e2fd1c2bc38..3d41eddb803 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -12,7 +12,7 @@ use rustc::ty::layout::{LayoutOf, HasTyCtxt}; use super::FunctionCx; use crate::traits::*; -pub fn non_ssa_locals<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( fx: &FunctionCx<'a, 'tcx, Bx> ) -> BitSet { let mir = fx.mir; @@ -43,7 +43,7 @@ pub fn non_ssa_locals<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( analyzer.non_ssa_locals } -struct LocalAnalyzer<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> { +struct LocalAnalyzer<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> { fx: &'mir FunctionCx<'a, 'tcx, Bx>, dominators: Dominators, non_ssa_locals: BitSet, @@ -94,7 +94,7 @@ impl> LocalAnalyzer<'mir, 'a, 'tcx, Bx> { } } -impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> +impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx, Bx> { fn visit_assign(&mut self, place: &mir::Place<'tcx>, diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index e4b82d84966..b4acc400546 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -151,7 +151,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'a, 'tcx> { } /// Codegen implementations for some terminator variants. -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { /// Generates code for a `Resume` terminator. fn codegen_resume_terminator<'b>( &mut self, @@ -788,7 +788,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_block( &mut self, bb: mir::BasicBlock, diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 78c22206ab7..d6951b923bf 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -8,7 +8,7 @@ use crate::traits::*; use super::FunctionCx; -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn eval_mir_constant( &mut self, constant: &mir::Constant<'tcx>, diff --git a/src/librustc_codegen_ssa/mir/mod.rs b/src/librustc_codegen_ssa/mir/mod.rs index dd69d358313..78af71b5a49 100644 --- a/src/librustc_codegen_ssa/mir/mod.rs +++ b/src/librustc_codegen_ssa/mir/mod.rs @@ -23,7 +23,7 @@ use rustc::mir::traversal; use self::operand::{OperandRef, OperandValue}; /// Master context for codegenning from MIR. -pub struct FunctionCx<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> { +pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> { instance: Instance<'tcx>, mir: &'a mir::Body<'tcx>, @@ -87,7 +87,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> { va_list_ref: Option>, } -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx> { @@ -167,7 +167,7 @@ enum LocalRef<'tcx, V> { Operand(Option>), } -impl<'a, 'tcx: 'a, V: CodegenObject> LocalRef<'tcx, V> { +impl<'a, 'tcx, V: CodegenObject> LocalRef<'tcx, V> { fn new_operand>( bx: &mut Bx, layout: TyLayout<'tcx>, @@ -185,7 +185,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> LocalRef<'tcx, V> { /////////////////////////////////////////////////////////////////////////// -pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cx: &'a Bx::CodegenCx, llfn: Bx::Value, mir: &'a Body<'tcx>, @@ -351,7 +351,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( } } -fn create_funclets<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( mir: &'a Body<'tcx>, bx: &mut Bx, cleanup_kinds: &IndexVec, @@ -420,7 +420,7 @@ fn create_funclets<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( /// Produces, for each argument, a `Value` pointing at the /// argument's value. As arguments are places, these are always /// indirect. -fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, fx: &FunctionCx<'a, 'tcx, Bx>, memory_locals: &BitSet, diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index b4303cf5c9b..3305dfe1ffb 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -53,7 +53,7 @@ impl fmt::Debug for OperandRef<'tcx, V> { } } -impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { +impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { pub fn new_zst>( bx: &mut Bx, layout: TyLayout<'tcx> @@ -266,7 +266,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { } } -impl<'a, 'tcx: 'a, V: CodegenObject> OperandValue { +impl<'a, 'tcx, V: CodegenObject> OperandValue { pub fn store>( self, bx: &mut Bx, @@ -376,7 +376,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandValue { } } -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn maybe_codegen_consume_direct( &mut self, bx: &mut Bx, diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 27311d0a8fb..81b17d0bee8 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -26,7 +26,7 @@ pub struct PlaceRef<'tcx, V> { pub align: Align, } -impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { +impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { pub fn new_sized( llval: V, layout: TyLayout<'tcx>, @@ -98,7 +98,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { } -impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { +impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { /// Access a field, at a point when the value's case is known. pub fn project_field>( self, bx: &mut Bx, @@ -386,7 +386,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { } } -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_place( &mut self, bx: &mut Bx, diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 87e15ba6aac..4a1971e3e2e 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -18,7 +18,7 @@ use super::{FunctionCx, LocalRef}; use super::operand::{OperandRef, OperandValue}; use super::place::PlaceRef; -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_rvalue( &mut self, mut bx: Bx, @@ -687,7 +687,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>) -> bool { match *rvalue { mir::Rvalue::Ref(..) | @@ -712,7 +712,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } -fn cast_int_to_float<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +fn cast_int_to_float<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, signed: bool, x: Bx::Value, @@ -746,7 +746,7 @@ fn cast_int_to_float<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( } } -fn cast_float_to_int<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>( +fn cast_float_to_int<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, signed: bool, x: Bx::Value, diff --git a/src/librustc_codegen_ssa/mir/statement.rs b/src/librustc_codegen_ssa/mir/statement.rs index 618d05245d2..750b2f5b1a5 100644 --- a/src/librustc_codegen_ssa/mir/statement.rs +++ b/src/librustc_codegen_ssa/mir/statement.rs @@ -6,7 +6,7 @@ use super::LocalRef; use super::OperandValue; use crate::traits::*; -impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn codegen_statement( &mut self, mut bx: Bx, diff --git a/src/librustc_codegen_ssa/mono_item.rs b/src/librustc_codegen_ssa/mono_item.rs index dc50c0e19ef..57bd2f36dd7 100644 --- a/src/librustc_codegen_ssa/mono_item.rs +++ b/src/librustc_codegen_ssa/mono_item.rs @@ -6,7 +6,7 @@ use crate::traits::*; use rustc::mir::mono::MonoItem; -pub trait MonoItemExt<'a, 'tcx: 'a> { +pub trait MonoItemExt<'a, 'tcx> { fn define>(&self, cx: &'a Bx::CodegenCx); fn predefine>( &self, @@ -17,7 +17,7 @@ pub trait MonoItemExt<'a, 'tcx: 'a> { fn to_raw_string(&self) -> String; } -impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { +impl<'a, 'tcx> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> { fn define>(&self, cx: &'a Bx::CodegenCx) { debug!("BEGIN IMPLEMENTING '{} ({})' in cgu {}", self.to_string(cx.tcx(), true), diff --git a/src/librustc_codegen_ssa/traits/backend.rs b/src/librustc_codegen_ssa/traits/backend.rs index 2f95c9a7d8b..f2edff2faac 100644 --- a/src/librustc_codegen_ssa/traits/backend.rs +++ b/src/librustc_codegen_ssa/traits/backend.rs @@ -44,7 +44,7 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se mods: &mut Self::Module, kind: AllocatorKind, ); - fn compile_codegen_unit<'a, 'tcx: 'a>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString); + fn compile_codegen_unit<'a, 'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString); // If find_features is true this won't access `sess.crate_types` by assuming // that `is_pie_binary` is false. When we discover LLVM target features // `sess.crate_types` is uninitialized so we cannot access it. diff --git a/src/librustc_codegen_ssa/traits/builder.rs b/src/librustc_codegen_ssa/traits/builder.rs index 2af57bcb064..1c80e614db8 100644 --- a/src/librustc_codegen_ssa/traits/builder.rs +++ b/src/librustc_codegen_ssa/traits/builder.rs @@ -22,7 +22,7 @@ pub enum OverflowOp { Mul, } -pub trait BuilderMethods<'a, 'tcx: 'a>: +pub trait BuilderMethods<'a, 'tcx>: HasCodegen<'tcx> + DebugInfoBuilderMethods<'tcx> + ArgTypeMethods<'tcx> diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 683da5865cd..eb89b5c1e63 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -453,7 +453,7 @@ impl<'a> pprust::PpAnn for HygieneAnnotation<'a> { } } -struct TypedAnnotation<'a, 'tcx: 'a> { +struct TypedAnnotation<'a, 'tcx> { tcx: TyCtxt<'tcx>, tables: Cell<&'a ty::TypeckTables<'tcx>>, } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index f3b94085693..c6f361855c7 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1088,7 +1088,7 @@ impl TypeAliasBounds { // We use a HIR visitor to walk the type. use rustc::hir::intravisit::{self, Visitor}; - struct WalkAssocTypes<'a, 'db> where 'db: 'a { + struct WalkAssocTypes<'a, 'db> where 'db { err: &'a mut DiagnosticBuilder<'db> } impl<'a, 'db, 'v> Visitor<'v> for WalkAssocTypes<'a, 'db> { diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 9fc23e45d20..2b99e2d9144 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -505,7 +505,7 @@ declare_lint! { declare_lint_pass!(ImproperCTypes => [IMPROPER_CTYPES]); -struct ImproperCTypesVisitor<'a, 'tcx: 'a> { +struct ImproperCTypesVisitor<'a, 'tcx> { cx: &'a LateContext<'a, 'tcx>, } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 5fef8e53e1d..ff523c7b68a 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -295,7 +295,7 @@ impl<'a> CrateLoader<'a> { path_kind: PathKind, ) -> Option<(LoadResult, Option)> where - 'a: 'b + 'a { // Use a new locator Context so trying to load a proc macro doesn't affect the error // message we emit diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 4bafe16b8e6..98cdeb69968 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -35,7 +35,7 @@ use syntax::ext::hygiene::Mark; use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION}; use log::debug; -pub struct DecodeContext<'a, 'tcx: 'a> { +pub struct DecodeContext<'a, 'tcx> { opaque: opaque::Decoder<'a>, cdata: Option<&'a CrateMetadata>, sess: Option<&'a Session>, @@ -128,7 +128,7 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, TyCtxt<'tcx>) { } } -impl<'a, 'tcx: 'a, T: Decodable> Lazy { +impl<'a, 'tcx, T: Decodable> Lazy { pub fn decode>(self, meta: M) -> T { let mut dcx = meta.decoder(self.position); dcx.lazy_state = LazyState::NodeStart(self.position); @@ -136,7 +136,7 @@ impl<'a, 'tcx: 'a, T: Decodable> Lazy { } } -impl<'a, 'tcx: 'a, T: Decodable> LazySeq { +impl<'a, 'tcx, T: Decodable> LazySeq { pub fn decode>( self, meta: M, diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index f6f2cfbfc08..40d8173ce40 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -160,7 +160,7 @@ impl<'tcx> BorrowSet<'tcx> { } } -struct GatherBorrows<'a, 'tcx: 'a> { +struct GatherBorrows<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, idx_vec: IndexVec>, diff --git a/src/librustc_mir/borrow_check/flows.rs b/src/librustc_mir/borrow_check/flows.rs index 5a57db2a672..9a9310fbe05 100644 --- a/src/librustc_mir/borrow_check/flows.rs +++ b/src/librustc_mir/borrow_check/flows.rs @@ -22,7 +22,7 @@ use std::fmt; use std::rc::Rc; // (forced to be `pub` due to its use as an associated type below.) -crate struct Flows<'b, 'tcx: 'b> { +crate struct Flows<'b, 'tcx> { borrows: FlowAtLocation<'tcx, Borrows<'b, 'tcx>>, pub uninits: FlowAtLocation<'tcx, MaybeUninitializedPlaces<'b, 'tcx>>, pub ever_inits: FlowAtLocation<'tcx, EverInitializedPlaces<'b, 'tcx>>, diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index c4a11efe5bc..a21d585a13c 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -423,7 +423,7 @@ fn downgrade_if_error(diag: &mut Diagnostic) { } } -pub struct MirBorrowckCtxt<'cx, 'tcx: 'cx> { +pub struct MirBorrowckCtxt<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, body: &'cx Body<'tcx>, mir_def_id: DefId, @@ -891,7 +891,7 @@ enum InitializationRequiringAction { PartialAssignment, } -struct RootPlace<'d, 'tcx: 'd> { +struct RootPlace<'d, 'tcx> { place: &'d Place<'tcx>, is_local_mutation_allowed: LocalMutationIsAllowed, } @@ -1693,7 +1693,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn move_path_closest_to<'a>( &mut self, place: &'a Place<'tcx>, - ) -> Result<(&'a Place<'tcx>, MovePathIndex), NoMovePathFound> where 'cx: 'a { + ) -> Result<(&'a Place<'tcx>, MovePathIndex), NoMovePathFound> where 'cx { let mut last_prefix = place; for prefix in self.prefixes(place, PrefixSet::All) { if let Some(mpi) = self.move_path_for_place(prefix) { diff --git a/src/librustc_mir/borrow_check/nll/constraint_generation.rs b/src/librustc_mir/borrow_check/nll/constraint_generation.rs index 18c542de272..058cdec5cea 100644 --- a/src/librustc_mir/borrow_check/nll/constraint_generation.rs +++ b/src/librustc_mir/borrow_check/nll/constraint_generation.rs @@ -35,7 +35,7 @@ pub(super) fn generate_constraints<'cx, 'tcx>( } /// 'cg = the duration of the constraint generation process itself. -struct ConstraintGeneration<'cg, 'cx: 'cg, 'tcx: 'cx> { +struct ConstraintGeneration<'cg, 'cx, 'tcx> { infcx: &'cg InferCtxt<'cx, 'tcx>, all_facts: &'cg mut Option, location_table: &'cg LocationTable, diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs index 4d7ab90a4b3..7ab069260f9 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs @@ -27,7 +27,7 @@ crate fn find<'tcx>( uf.find() } -struct UseFinder<'cx, 'tcx: 'cx> { +struct UseFinder<'cx, 'tcx> { body: &'cx Body<'tcx>, regioncx: &'cx Rc>, tcx: TyCtxt<'tcx>, @@ -99,7 +99,7 @@ impl<'cx, 'tcx> UseFinder<'cx, 'tcx> { } } -struct DefUseVisitor<'cx, 'tcx: 'cx> { +struct DefUseVisitor<'cx, 'tcx> { body: &'cx Body<'tcx>, tcx: TyCtxt<'tcx>, region_vid: RegionVid, diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 286f3ac5ccd..c45c28c6146 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -43,7 +43,7 @@ pub(super) fn generate_invalidates<'tcx>( } } -struct InvalidationGenerator<'cx, 'tcx: 'cx> { +struct InvalidationGenerator<'cx, 'tcx> { tcx: TyCtxt<'tcx>, all_facts: &'cx mut AllFacts, location_table: &'cx LocationTable, diff --git a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs index cffc66ac7dd..0cf8a0d16f6 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs @@ -29,7 +29,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } } -struct RawConstraints<'a, 'tcx: 'a> { +struct RawConstraints<'a, 'tcx> { regioncx: &'a RegionInferenceContext<'tcx>, } @@ -78,7 +78,7 @@ impl<'a, 'this, 'tcx> dot::GraphWalk<'this> for RawConstraints<'a, 'tcx> { } } -struct SccConstraints<'a, 'tcx: 'a> { +struct SccConstraints<'a, 'tcx> { regioncx: &'a RegionInferenceContext<'tcx>, nodes_per_scc: IndexVec>, } diff --git a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs index d86702773e3..77a4d2699ff 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs @@ -13,7 +13,7 @@ use rustc::ty::subst::UnpackedKind; use rustc::ty::{self, TyCtxt}; use syntax_pos::DUMMY_SP; -crate struct ConstraintConversion<'a, 'tcx: 'a> { +crate struct ConstraintConversion<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, tcx: TyCtxt<'tcx>, universal_regions: &'a UniversalRegions<'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs index ca42f249dc1..1bb3acc28f0 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs @@ -219,7 +219,7 @@ impl UniversalRegionRelations<'tcx> { } } -struct UniversalRegionRelationsBuilder<'this, 'tcx: 'this> { +struct UniversalRegionRelationsBuilder<'this, 'tcx> { infcx: &'this InferCtxt<'this, 'tcx>, param_env: ty::ParamEnv<'tcx>, universal_regions: Rc>, diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs index 48e45e94525..2d65eb021d3 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs @@ -60,9 +60,9 @@ pub(super) fn trace( /// Contextual state for the type-liveness generator. struct LivenessContext<'me, 'typeck, 'flow, 'tcx> where - 'typeck: 'me, - 'flow: 'me, - 'tcx: 'typeck + 'flow, + 'typeck, + 'flow, + 'tcx, { /// Current type-checker, giving us our inference context etc. typeck: &'me mut TypeChecker<'typeck, 'tcx>, @@ -98,9 +98,9 @@ struct DropData<'tcx> { struct LivenessResults<'me, 'typeck, 'flow, 'tcx> where - 'typeck: 'me, - 'flow: 'me, - 'tcx: 'typeck + 'flow, + 'typeck, + 'flow, + 'tcx, { cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index ad79f210920..ac5efa46406 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -251,7 +251,7 @@ enum FieldAccessError { /// The sanitize_XYZ methods here take an MIR object and compute its /// type, calling `span_mirbug` and returning an error type if there /// is a problem. -struct TypeVerifier<'a, 'b: 'a, 'tcx: 'b> { +struct TypeVerifier<'a, 'b, 'tcx> { cx: &'a mut TypeChecker<'b, 'tcx>, body: &'b Body<'tcx>, last_span: Span, @@ -830,7 +830,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { /// constraints needed for it to be valid and well-typed. Along the /// way, it accrues region constraints -- these can later be used by /// NLL region checking. -struct TypeChecker<'a, 'tcx: 'a> { +struct TypeChecker<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, param_env: ty::ParamEnv<'tcx>, last_span: Span, @@ -845,7 +845,7 @@ struct TypeChecker<'a, 'tcx: 'a> { universal_region_relations: &'a UniversalRegionRelations<'tcx>, } -struct BorrowCheckContext<'a, 'tcx: 'a> { +struct BorrowCheckContext<'a, 'tcx> { universal_regions: &'a UniversalRegions<'tcx>, location_table: &'a LocationTable, all_facts: &'a mut Option, diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs index 5ced356299f..2549aa4fbff 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs @@ -34,7 +34,7 @@ pub(super) fn relate_types<'tcx>( Ok(()) } -struct NllTypeRelatingDelegate<'me, 'bccx: 'me, 'tcx: 'bccx> { +struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { infcx: &'me InferCtxt<'me, 'tcx>, borrowck_context: Option<&'me mut BorrowCheckContext<'bccx, 'tcx>>, diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index a236359f1d4..fa3c7b9613e 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -363,7 +363,7 @@ impl<'tcx> UniversalRegions<'tcx> { } } -struct UniversalRegionsBuilder<'cx, 'tcx: 'cx> { +struct UniversalRegionsBuilder<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, mir_def_id: DefId, mir_hir_id: HirId, diff --git a/src/librustc_mir/borrow_check/prefixes.rs b/src/librustc_mir/borrow_check/prefixes.rs index b35bcc09a23..0cc1dfd4def 100644 --- a/src/librustc_mir/borrow_check/prefixes.rs +++ b/src/librustc_mir/borrow_check/prefixes.rs @@ -36,7 +36,7 @@ impl<'tcx> IsPrefixOf<'tcx> for Place<'tcx> { } } -pub(super) struct Prefixes<'cx, 'tcx: 'cx> { +pub(super) struct Prefixes<'cx, 'tcx> { body: &'cx Body<'tcx>, tcx: TyCtxt<'tcx>, kind: PrefixSet, diff --git a/src/librustc_mir/borrow_check/used_muts.rs b/src/librustc_mir/borrow_check/used_muts.rs index e609ddbbe95..9c5569011df 100644 --- a/src/librustc_mir/borrow_check/used_muts.rs +++ b/src/librustc_mir/borrow_check/used_muts.rs @@ -46,7 +46,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// MIR visitor for collecting used mutable variables. /// The 'visit lifetime represents the duration of the MIR walk. -struct GatherUsedMutsVisitor<'visit, 'cx: 'visit, 'tcx: 'cx> { +struct GatherUsedMutsVisitor<'visit, 'cx, 'tcx> { temporary_used_locals: FxHashSet, never_initialized_mut_locals: &'visit mut FxHashSet, mbcx: &'visit mut MirBorrowckCtxt<'cx, 'tcx>, diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 134ff52efe1..54f93523182 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -661,7 +661,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[derive(Debug)] -pub struct Candidate<'pat, 'tcx: 'pat> { +pub struct Candidate<'pat, 'tcx> { // span of the original pattern that gave rise to this candidate span: Span, @@ -705,7 +705,7 @@ struct Ascription<'tcx> { } #[derive(Clone, Debug)] -pub struct MatchPair<'pat, 'tcx: 'pat> { +pub struct MatchPair<'pat, 'tcx> { // this place... place: Place<'tcx>, @@ -1691,7 +1691,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, block: BasicBlock, bindings: impl IntoIterator>, - ) where 'tcx: 'b { + ) where 'tcx { debug!("bind_matched_candidate_for_arm_body(block={:?})", block); let re_erased = self.hir.tcx().lifetimes.re_erased; diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index a0e45caeb6b..001f377c0ee 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -241,7 +241,7 @@ impl BlockFrame { #[derive(Debug)] struct BlockContext(Vec); -struct Builder<'a, 'tcx: 'a> { +struct Builder<'a, 'tcx> { hir: Cx<'a, 'tcx>, cfg: CFG<'tcx>, diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs index a5e1b4ebaaf..069ce3a78c5 100644 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -11,11 +11,11 @@ use crate::dataflow::BitDenotation; /// This is used to compute which locals are live during a yield expression for /// immovable generators. #[derive(Copy, Clone)] -pub struct HaveBeenBorrowedLocals<'a, 'tcx: 'a> { +pub struct HaveBeenBorrowedLocals<'a, 'tcx> { body: &'a Body<'tcx>, } -impl<'a, 'tcx: 'a> HaveBeenBorrowedLocals<'a, 'tcx> { +impl<'a, 'tcx> HaveBeenBorrowedLocals<'a, 'tcx> { pub fn new(body: &'a Body<'tcx>) -> Self { HaveBeenBorrowedLocals { body } @@ -97,7 +97,7 @@ impl<'a, 'tcx> InitialFlow for HaveBeenBorrowedLocals<'a, 'tcx> { } } -struct BorrowedLocalsVisitor<'b, 'c: 'b> { +struct BorrowedLocalsVisitor<'b, 'c> { sets: &'b mut BlockSets<'c, Local>, } diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index ba1a22c8d42..899765a1d2d 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -29,7 +29,7 @@ newtype_index! { /// `BorrowIndex`, and maps each such index to a `BorrowData` /// describing the borrow. These indexes are used for representing the /// borrows in compact bitvectors. -pub struct Borrows<'a, 'tcx: 'a> { +pub struct Borrows<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 50d9bbf4cc3..0a572d20936 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -63,7 +63,7 @@ pub(super) mod borrows; /// Similarly, at a given `drop` statement, the set-intersection /// between this data and `MaybeUninitializedPlaces` yields the set of /// places that would require a dynamic drop-flag at that statement. -pub struct MaybeInitializedPlaces<'a, 'tcx: 'a> { +pub struct MaybeInitializedPlaces<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>, @@ -114,7 +114,7 @@ impl<'a, 'tcx> HasMoveData<'tcx> for MaybeInitializedPlaces<'a, 'tcx> { /// Similarly, at a given `drop` statement, the set-intersection /// between this data and `MaybeInitializedPlaces` yields the set of /// places that would require a dynamic drop-flag at that statement. -pub struct MaybeUninitializedPlaces<'a, 'tcx: 'a> { +pub struct MaybeUninitializedPlaces<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>, @@ -164,19 +164,19 @@ impl<'a, 'tcx> HasMoveData<'tcx> for MaybeUninitializedPlaces<'a, 'tcx> { /// Similarly, at a given `drop` statement, the set-difference between /// this data and `MaybeInitializedPlaces` yields the set of places /// that would require a dynamic drop-flag at that statement. -pub struct DefinitelyInitializedPlaces<'a, 'tcx: 'a> { +pub struct DefinitelyInitializedPlaces<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>, } -impl<'a, 'tcx: 'a> DefinitelyInitializedPlaces<'a, 'tcx> { +impl<'a, 'tcx> DefinitelyInitializedPlaces<'a, 'tcx> { pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self { DefinitelyInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } } -impl<'a, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> { +impl<'a, 'tcx> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> { fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data } } @@ -209,13 +209,13 @@ impl<'a, 'tcx: 'a> HasMoveData<'tcx> for DefinitelyInitializedPlaces<'a, 'tcx> { /// c = S; // {a, b, c, d } /// } /// ``` -pub struct EverInitializedPlaces<'a, 'tcx: 'a> { +pub struct EverInitializedPlaces<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>, } -impl<'a, 'tcx: 'a> EverInitializedPlaces<'a, 'tcx> { +impl<'a, 'tcx> EverInitializedPlaces<'a, 'tcx> { pub fn new(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, mdpe: &'a MoveDataParamEnv<'tcx>) -> Self { EverInitializedPlaces { tcx: tcx, body: body, mdpe: mdpe } } diff --git a/src/librustc_mir/dataflow/impls/storage_liveness.rs b/src/librustc_mir/dataflow/impls/storage_liveness.rs index fed56e987ef..d7575b0f441 100644 --- a/src/librustc_mir/dataflow/impls/storage_liveness.rs +++ b/src/librustc_mir/dataflow/impls/storage_liveness.rs @@ -4,11 +4,11 @@ use rustc::mir::*; use crate::dataflow::BitDenotation; #[derive(Copy, Clone)] -pub struct MaybeStorageLive<'a, 'tcx: 'a> { +pub struct MaybeStorageLive<'a, 'tcx> { body: &'a Body<'tcx>, } -impl<'a, 'tcx: 'a> MaybeStorageLive<'a, 'tcx> { +impl<'a, 'tcx> MaybeStorageLive<'a, 'tcx> { pub fn new(body: &'a Body<'tcx>) -> Self { MaybeStorageLive { body } diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 8c4acd70456..1130e7e3f5d 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -41,7 +41,7 @@ pub(crate) mod indexes { }; } -pub(crate) struct DataflowBuilder<'a, 'tcx: 'a, BD> +pub(crate) struct DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tcx> { @@ -86,7 +86,7 @@ pub(crate) trait Dataflow<'tcx, BD: BitDenotation<'tcx>> { fn propagate(&mut self); } -impl<'a, 'tcx: 'a, BD> Dataflow<'tcx, BD> for DataflowBuilder<'a, 'tcx, BD> +impl<'a, 'tcx, BD> Dataflow<'tcx, BD> for DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tcx> { @@ -138,7 +138,7 @@ where flow_state.run(tcx, def_id, attributes, p) } -impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> +impl<'a, 'tcx, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx>, { @@ -179,12 +179,12 @@ where } } -struct PropagationContext<'b, 'a: 'b, 'tcx: 'a, O> where O: 'b + BitDenotation<'tcx> +struct PropagationContext<'b, 'a, 'tcx, O> where O: 'b + BitDenotation<'tcx> { builder: &'b mut DataflowAnalysis<'a, 'tcx, O>, } -impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx> +impl<'a, 'tcx, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx> { fn propagate(&mut self) { let mut temp = BitSet::new_empty(self.flow_state.sets.bits_per_block); @@ -234,7 +234,7 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'t } } -impl<'b, 'a: 'b, 'tcx: 'a, BD> PropagationContext<'b, 'a, 'tcx, BD> where BD: BitDenotation<'tcx> +impl<'b, 'a, 'tcx, BD> PropagationContext<'b, 'a, 'tcx, BD> where BD: BitDenotation<'tcx> { fn walk_cfg(&mut self, in_out: &mut BitSet) { let mut dirty_queue: WorkQueue = @@ -265,7 +265,7 @@ fn dataflow_path(context: &str, path: &str) -> PathBuf { path } -impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tcx> +impl<'a, 'tcx, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tcx> { fn pre_dataflow_instrumentation

(&self, p: P) -> io::Result<()> where P: Fn(&BD, BD::Idx) -> DebugFormatted @@ -297,7 +297,7 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tc /// underlying flow analysis results, because it needs to handle cases /// where we are combining the results of *multiple* flow analyses /// (e.g., borrows + inits + uninits). -pub(crate) trait DataflowResultsConsumer<'a, 'tcx: 'a> { +pub(crate) trait DataflowResultsConsumer<'a, 'tcx> { type FlowState: FlowsAtLocation; // Observation Hooks: override (at least one of) these to get analysis feedback. @@ -387,14 +387,14 @@ pub fn state_for_location<'tcx, T: BitDenotation<'tcx>>(loc: Location, gen_set.to_dense() } -pub struct DataflowAnalysis<'a, 'tcx: 'a, O> where O: BitDenotation<'tcx> +pub struct DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation<'tcx> { flow_state: DataflowState<'tcx, O>, dead_unwinds: &'a BitSet, body: &'a Body<'tcx>, } -impl<'a, 'tcx: 'a, O> DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation<'tcx> +impl<'a, 'tcx, O> DataflowAnalysis<'a, 'tcx, O> where O: BitDenotation<'tcx> { pub fn results(self) -> DataflowResults<'tcx, O> { DataflowResults(self.flow_state) @@ -734,7 +734,7 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation<'tcx> } } -impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation<'tcx> { +impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation<'tcx> { /// Propagates the bits of `in_out` into all the successors of `bb`, /// using bitwise operator denoted by `self.operator`. /// diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 7c738b75e07..e8386e8fef1 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -12,7 +12,7 @@ use super::{LocationMap, MoveData, MovePath, MovePathLookup, MovePathIndex, Move use super::{MoveError, InitIndex, Init, InitLocation, LookupResult, InitKind}; use super::IllegalMoveOriginKind::*; -struct MoveDataBuilder<'a, 'tcx: 'a> { +struct MoveDataBuilder<'a, 'tcx> { body: &'a Body<'tcx>, tcx: TyCtxt<'tcx>, data: MoveData<'tcx>, @@ -253,7 +253,7 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> { } } -struct Gatherer<'b, 'a: 'b, 'tcx: 'a> { +struct Gatherer<'b, 'a, 'tcx> { builder: &'b mut MoveDataBuilder<'a, 'tcx>, loc: Location, } diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index ff53cf02d8d..fe54e2a0f18 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -21,7 +21,7 @@ use rustc::hir; use crate::hair::constant::{lit_to_const, LitToConstError}; #[derive(Clone)] -pub struct Cx<'a, 'tcx: 'a> { +pub struct Cx<'a, 'tcx> { tcx: TyCtxt<'tcx>, infcx: &'a InferCtxt<'a, 'tcx>, diff --git a/src/librustc_mir/hair/cx/to_ref.rs b/src/librustc_mir/hair/cx/to_ref.rs index a462c61c2ac..d044b1faedf 100644 --- a/src/librustc_mir/hair/cx/to_ref.rs +++ b/src/librustc_mir/hair/cx/to_ref.rs @@ -8,7 +8,7 @@ pub trait ToRef { fn to_ref(self) -> Self::Output; } -impl<'a, 'tcx: 'a> ToRef for &'tcx hir::Expr { +impl<'a, 'tcx> ToRef for &'tcx hir::Expr { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { @@ -16,7 +16,7 @@ impl<'a, 'tcx: 'a> ToRef for &'tcx hir::Expr { } } -impl<'a, 'tcx: 'a> ToRef for &'tcx P { +impl<'a, 'tcx> ToRef for &'tcx P { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { @@ -24,7 +24,7 @@ impl<'a, 'tcx: 'a> ToRef for &'tcx P { } } -impl<'a, 'tcx: 'a> ToRef for Expr<'tcx> { +impl<'a, 'tcx> ToRef for Expr<'tcx> { type Output = ExprRef<'tcx>; fn to_ref(self) -> ExprRef<'tcx> { @@ -32,7 +32,7 @@ impl<'a, 'tcx: 'a> ToRef for Expr<'tcx> { } } -impl<'a, 'tcx: 'a, T, U> ToRef for &'tcx Option +impl<'a, 'tcx, T, U> ToRef for &'tcx Option where &'tcx T: ToRef { type Output = Option; @@ -42,7 +42,7 @@ impl<'a, 'tcx: 'a, T, U> ToRef for &'tcx Option } } -impl<'a, 'tcx: 'a, T, U> ToRef for &'tcx Vec +impl<'a, 'tcx, T, U> ToRef for &'tcx Vec where &'tcx T: ToRef { type Output = Vec; @@ -52,7 +52,7 @@ impl<'a, 'tcx: 'a, T, U> ToRef for &'tcx Vec } } -impl<'a, 'tcx: 'a, T, U> ToRef for &'tcx P<[T]> +impl<'a, 'tcx, T, U> ToRef for &'tcx P<[T]> where &'tcx T: ToRef { type Output = Vec; diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index bb1a67bcdae..22bd802c1fa 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -285,7 +285,7 @@ impl<'tcx> Pattern<'tcx> { /// A 2D matrix. Nx1 matrices are very common, which is why `SmallVec[_; 2]` /// works well for each row. -pub struct Matrix<'p, 'tcx: 'p>(Vec; 2]>>); +pub struct Matrix<'p, 'tcx>(Vec; 2]>>); impl<'p, 'tcx> Matrix<'p, 'tcx> { pub fn empty() -> Self { @@ -349,7 +349,7 @@ impl<'p, 'tcx> FromIterator; 2]>> for Matrix<'p, 'tc } } -pub struct MatchCheckCtxt<'a, 'tcx: 'a> { +pub struct MatchCheckCtxt<'a, 'tcx> { pub tcx: TyCtxt<'tcx>, /// The module in which the match occurs. This is necessary for /// checking inhabited-ness of types because whether a type is (visibly) @@ -393,7 +393,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> { } fn is_non_exhaustive_variant<'p>(&self, pattern: &'p Pattern<'tcx>) -> bool - where 'a: 'p + where 'a { match *pattern.kind { PatternKind::Variant { adt_def, variant_index, .. } => { @@ -634,7 +634,7 @@ impl<'tcx> Witness<'tcx> { /// /// We make sure to omit constructors that are statically impossible. E.g., for /// `Option`, we do not include `Some(_)` in the returned list of constructors. -fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, +fn all_constructors<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>, pcx: PatternContext<'tcx>) -> Vec> { @@ -708,7 +708,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, ctors } -fn max_slice_length<'p, 'a: 'p, 'tcx: 'a, I>( +fn max_slice_length<'p, 'a, 'tcx, I>( cx: &mut MatchCheckCtxt<'a, 'tcx>, patterns: I) -> u64 where I: Iterator> @@ -985,7 +985,7 @@ enum MissingCtors<'tcx> { // (The split logic gives a performance win, because we always need to know if // the set is empty, but we rarely need the full set, and it can be expensive // to compute the full set.) -fn compute_missing_ctors<'a, 'tcx: 'a>( +fn compute_missing_ctors<'a, 'tcx>( info: MissingCtorsInfo, tcx: TyCtxt<'tcx>, all_ctors: &Vec>, @@ -1057,7 +1057,7 @@ fn compute_missing_ctors<'a, 'tcx: 'a>( /// relation to preceding patterns, it is not reachable) and exhaustiveness /// checking (if a wildcard pattern is useful in relation to a matrix, the /// matrix isn't exhaustive). -pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, +pub fn is_useful<'p, 'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>, matrix: &Matrix<'p, 'tcx>, v: &[&Pattern<'tcx>], witness: WitnessPreference) @@ -1267,7 +1267,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, /// A shorthand for the `U(S(c, P), S(c, q))` operation from the paper. I.e., `is_useful` applied /// to the specialised version of both the pattern matrix `P` and the new pattern `q`. -fn is_useful_specialized<'p, 'a: 'p, 'tcx: 'a>( +fn is_useful_specialized<'p, 'a, 'tcx>( cx: &mut MatchCheckCtxt<'a, 'tcx>, &Matrix(ref m): &Matrix<'p, 'tcx>, v: &[&Pattern<'tcx>], @@ -1373,7 +1373,7 @@ fn constructor_arity(cx: &MatchCheckCtxt<'a, 'tcx>, ctor: &Constructor<'tcx>, ty /// expanded to. /// /// For instance, a tuple pattern (43u32, 'a') has sub pattern types [u32, char]. -fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>, +fn constructor_sub_pattern_tys<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, ctor: &Constructor<'tcx>, ty: Ty<'tcx>) -> Vec> { @@ -1520,7 +1520,7 @@ fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>) /// boundaries for each interval range, sort them, then create constructors for each new interval /// between every pair of boundary points. (This essentially sums up to performing the intuitive /// merging operation depicted above.) -fn split_grouped_constructors<'p, 'a: 'p, 'tcx: 'a>( +fn split_grouped_constructors<'p, 'a, 'tcx>( tcx: TyCtxt<'tcx>, ctors: Vec>, &Matrix(ref m): &Matrix<'p, 'tcx>, @@ -1598,7 +1598,7 @@ fn split_grouped_constructors<'p, 'a: 'p, 'tcx: 'a>( } /// Checks whether there exists any shared value in either `ctor` or `pat` by intersecting them. -fn constructor_intersects_pattern<'p, 'a: 'p, 'tcx: 'a>( +fn constructor_intersects_pattern<'p, 'a, 'tcx>( tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>, pat: &'p Pattern<'tcx>, @@ -1688,7 +1688,7 @@ fn constructor_covered_by_range<'tcx>( } } -fn patterns_for_variant<'p, 'a: 'p, 'tcx: 'a>( +fn patterns_for_variant<'p, 'a, 'tcx>( subpatterns: &'p [FieldPattern<'tcx>], wild_patterns: &[&'p Pattern<'tcx>]) -> SmallVec<[&'p Pattern<'tcx>; 2]> @@ -1711,7 +1711,7 @@ fn patterns_for_variant<'p, 'a: 'p, 'tcx: 'a>( /// different patterns. /// Structure patterns with a partial wild pattern (Foo { a: 42, .. }) have their missing /// fields filled with wild patterns. -fn specialize<'p, 'a: 'p, 'tcx: 'a>( +fn specialize<'p, 'a, 'tcx>( cx: &mut MatchCheckCtxt<'a, 'tcx>, r: &[&'p Pattern<'tcx>], constructor: &Constructor<'tcx>, diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 159b526bdba..ed850379af6 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -47,7 +47,7 @@ fn create_e0004<'a>(sess: &'a Session, sp: Span, error_message: String) -> Diagn struct_span_err!(sess, sp, E0004, "{}", &error_message) } -struct MatchVisitor<'a, 'tcx: 'a> { +struct MatchVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, body_owner: DefId, tables: &'a ty::TypeckTables<'tcx>, @@ -439,7 +439,7 @@ fn check_arms<'a, 'tcx>( } } -fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>( +fn check_exhaustive<'p, 'a, 'tcx>( cx: &mut MatchCheckCtxt<'a, 'tcx>, scrut_ty: Ty<'tcx>, sp: Span, @@ -642,7 +642,7 @@ fn check_for_mutation_in_guard(cx: &MatchVisitor<'_, '_>, guard: &hir::Guard) { }; } -struct MutationChecker<'a, 'tcx: 'a> { +struct MutationChecker<'a, 'tcx> { cx: &'a MatchVisitor<'a, 'tcx>, } @@ -691,7 +691,7 @@ fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pa AtBindingPatternVisitor { cx: cx, bindings_allowed: true }.visit_pat(pat); } -struct AtBindingPatternVisitor<'a, 'b:'a, 'tcx:'b> { +struct AtBindingPatternVisitor<'a, 'b, 'tcx> { cx: &'a MatchVisitor<'b, 'tcx>, bindings_allowed: bool } diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index e0e14852c57..cf597ce0b63 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -326,7 +326,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { } } -pub struct PatternContext<'a, 'tcx: 'a> { +pub struct PatternContext<'a, 'tcx> { pub tcx: TyCtxt<'tcx>, pub param_env: ty::ParamEnv<'tcx>, pub tables: &'a ty::TypeckTables<'tcx>, diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 28dc0d37b36..b01826c98db 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -49,7 +49,7 @@ pub struct InterpretCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> { /// A stack frame. #[derive(Clone)] -pub struct Frame<'mir, 'tcx: 'mir, Tag=(), Extra=()> { +pub struct Frame<'mir, 'tcx, Tag=(), Extra=()> { //////////////////////////////////////////////////////////////////////////////// // Function and callsite information //////////////////////////////////////////////////////////////////////////////// @@ -195,7 +195,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpretCx<'mir, 'tcx, M> } } -impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> { +impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> { pub fn new(tcx: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>, machine: M) -> Self { InterpretCx { machine, diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 0032e84b266..ad631793a08 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -304,7 +304,7 @@ impl_stable_hash_for!(enum crate::interpret::eval_context::StackPopCleanup { }); #[derive(Eq, PartialEq)] -struct FrameSnapshot<'a, 'tcx: 'a> { +struct FrameSnapshot<'a, 'tcx> { instance: &'a ty::Instance<'tcx>, span: &'a Span, return_to_block: &'a StackPopCleanup, diff --git a/src/librustc_mir/interpret/visitor.rs b/src/librustc_mir/interpret/visitor.rs index 9150f16526b..95a679b95dd 100644 --- a/src/librustc_mir/interpret/visitor.rs +++ b/src/librustc_mir/interpret/visitor.rs @@ -122,7 +122,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Value<'mir, 'tcx, M> for MPlaceTy<'tcx, macro_rules! make_value_visitor { ($visitor_trait_name:ident, $($mutability:ident)?) => { // How to traverse a value and what to do when we are at the leaves. - pub trait $visitor_trait_name<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized { + pub trait $visitor_trait_name<'mir, 'tcx, M: Machine<'mir, 'tcx>>: Sized { type V: Value<'mir, 'tcx, M>; /// The visitor must have an `InterpretCx` in it. diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 2e74ebcf061..6dcb23da321 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -345,7 +345,7 @@ fn collect_roots<'tcx>(tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode) -> Vec( +fn collect_items_rec<'a, 'tcx>( tcx: TyCtxt<'tcx>, starting_point: MonoItem<'tcx>, visited: MTRef<'_, MTLock>>>, @@ -515,7 +515,7 @@ fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) { } } -struct MirNeighborCollector<'a, 'tcx: 'a> { +struct MirNeighborCollector<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a mir::Body<'tcx>, output: &'a mut Vec>, diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index a821cb2cfda..59e95215df2 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -769,7 +769,7 @@ fn numbered_codegen_unit_name( fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'tcx>, label: &str, cgus: I) where I: Iterator>, - 'tcx: 'a + 'b, + 'tcx, { if cfg!(debug_assertions) { debug!("{}", label); @@ -794,7 +794,7 @@ where } #[inline(never)] // give this a place in the profiler -fn assert_symbols_are_distinct<'a, 'tcx: 'a, I>(tcx: TyCtxt<'tcx>, mono_items: I) +fn assert_symbols_are_distinct<'a, 'tcx, I>(tcx: TyCtxt<'tcx>, mono_items: I) where I: Iterator>, { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index f5a22ea0931..c04672f8331 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -248,7 +248,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>) body } -pub struct DropShimElaborator<'a, 'tcx: 'a> { +pub struct DropShimElaborator<'a, 'tcx> { pub body: &'a Body<'tcx>, pub patch: MirPatch<'tcx>, pub tcx: TyCtxt<'tcx>, diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 32153f7bcd9..9c78d761cb2 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -18,7 +18,7 @@ use std::ops::Bound; use crate::util; -pub struct UnsafetyChecker<'a, 'tcx: 'a> { +pub struct UnsafetyChecker<'a, 'tcx> { body: &'a Body<'tcx>, const_context: bool, min_const_fn: bool, diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 584a2fd1341..d805c66e3c3 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -164,7 +164,7 @@ impl InitializationData { } } -struct Elaborator<'a, 'b: 'a, 'tcx: 'b> { +struct Elaborator<'a, 'b, 'tcx> { init_data: &'a InitializationData, ctxt: &'a mut ElaborateDropsCtxt<'b, 'tcx>, } @@ -285,7 +285,7 @@ impl<'a, 'b, 'tcx> DropElaborator<'a, 'tcx> for Elaborator<'a, 'b, 'tcx> { } } -struct ElaborateDropsCtxt<'a, 'tcx: 'a> { +struct ElaborateDropsCtxt<'a, 'tcx> { tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, env: &'a MoveDataParamEnv<'tcx>, diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 9c7aedc12a2..6be54aa629d 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -616,7 +616,7 @@ fn compute_storage_conflicts( storage_conflicts } -struct StorageConflictVisitor<'body, 'tcx: 'body, 's> { +struct StorageConflictVisitor<'body, 'tcx, 's> { body: &'body Body<'tcx>, stored_locals: &'s liveness::LiveVarSet, // FIXME(tmandry): Consider using sparse bitsets here once we have good @@ -624,7 +624,7 @@ struct StorageConflictVisitor<'body, 'tcx: 'body, 's> { local_conflicts: BitMatrix, } -impl<'body, 'tcx: 'body, 's> DataflowResultsConsumer<'body, 'tcx> +impl<'body, 'tcx, 's> DataflowResultsConsumer<'body, 'tcx> for StorageConflictVisitor<'body, 'tcx, 's> { type FlowState = FlowAtLocation<'tcx, MaybeStorageLive<'body, 'tcx>>; @@ -654,7 +654,7 @@ for StorageConflictVisitor<'body, 'tcx, 's> { } } -impl<'body, 'tcx: 'body, 's> StorageConflictVisitor<'body, 'tcx, 's> { +impl<'body, 'tcx, 's> StorageConflictVisitor<'body, 'tcx, 's> { fn apply_state(&mut self, flow_state: &FlowAtLocation<'tcx, MaybeStorageLive<'body, 'tcx>>, loc: Location) { diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 5e6f1bc15f0..e2f98e46dba 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -643,7 +643,7 @@ fn type_size_of<'tcx>( * Updates block indices, references to locals and other control flow * stuff. */ -struct Integrator<'a, 'tcx: 'a> { +struct Integrator<'a, 'tcx> { block_idx: usize, args: &'a [Local], local_map: IndexVec, diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index 79bb2cfe08d..81d91dcd0a9 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -66,7 +66,7 @@ fn mir_keys<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> &'tcx DefIdSet { // Additionally, tuple struct/variant constructors have MIR, but // they don't have a BodyId, so we need to build them separately. - struct GatherCtors<'a, 'tcx: 'a> { + struct GatherCtors<'a, 'tcx> { tcx: TyCtxt<'tcx>, set: &'a mut DefIdSet, } diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 84d3f8f4c46..d78adfe433c 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -147,7 +147,7 @@ pub fn collect_temps(body: &Body<'_>, collector.temps } -struct Promoter<'a, 'tcx: 'a> { +struct Promoter<'a, 'tcx> { tcx: TyCtxt<'tcx>, source: &'a mut Body<'tcx>, promoted: Body<'tcx>, diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index ac15f52d9ec..f226f15c009 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -63,12 +63,12 @@ impl MirPass for SimplifyCfg { } } -pub struct CfgSimplifier<'a, 'tcx: 'a> { +pub struct CfgSimplifier<'a, 'tcx> { basic_blocks: &'a mut IndexVec>, pred_count: IndexVec } -impl<'a, 'tcx: 'a> CfgSimplifier<'a, 'tcx> { +impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { pub fn new(body: &'a mut Body<'tcx>) -> Self { let mut pred_count = IndexVec::from_elem(0u32, body.basic_blocks()); diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 90b52b76155..812a024e1d9 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -47,7 +47,7 @@ impl MirPass for UniformArrayMoveOut { } } -struct UniformArrayMoveOutVisitor<'a, 'tcx: 'a> { +struct UniformArrayMoveOutVisitor<'a, 'tcx> { body: &'a Body<'tcx>, patch: &'a mut MirPatch<'tcx>, tcx: TyCtxt<'tcx>, diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 0d7d6b4094a..6da181ef668 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -70,7 +70,7 @@ impl Unwind { } } -pub trait DropElaborator<'a, 'tcx: 'a>: fmt::Debug { +pub trait DropElaborator<'a, 'tcx>: fmt::Debug { type Path : Copy + fmt::Debug; fn patch(&mut self) -> &mut MirPatch<'tcx>; @@ -90,7 +90,7 @@ pub trait DropElaborator<'a, 'tcx: 'a>: fmt::Debug { } #[derive(Debug)] -struct DropCtxt<'l, 'b: 'l, 'tcx: 'b, D> +struct DropCtxt<'l, 'b, 'tcx, D> where D : DropElaborator<'b, 'tcx> + 'l { elaborator: &'l mut D, diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index efa4bd65c0b..e1e4195d6d5 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -39,7 +39,7 @@ enum Context { } #[derive(Copy, Clone)] -struct CheckLoopVisitor<'a, 'hir: 'a> { +struct CheckLoopVisitor<'a, 'hir> { sess: &'a Session, hir_map: &'a Map<'hir>, cx: Context, diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 5397a4af8fa..1493d029048 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -74,7 +74,7 @@ fn rvalue_promotable_map<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ItemLo tcx.arena.alloc(visitor.result) } -struct CheckCrateVisitor<'a, 'tcx: 'a> { +struct CheckCrateVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, in_fn: bool, in_static: bool, diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 9eaa6f920f0..ba834bf09aa 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -842,7 +842,7 @@ impl DefIdVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'tcx> { /// This pass performs remaining checks for fields in struct expressions and patterns. ////////////////////////////////////////////////////////////////////////////////////// -struct NamePrivacyVisitor<'a, 'tcx: 'a> { +struct NamePrivacyVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, current_item: hir::HirId, @@ -969,7 +969,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> { /// Checks are performed on "semantic" types regardless of names and their hygiene. //////////////////////////////////////////////////////////////////////////////////////////// -struct TypePrivacyVisitor<'a, 'tcx: 'a> { +struct TypePrivacyVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, tables: &'a ty::TypeckTables<'tcx>, current_item: DefId, @@ -1202,7 +1202,7 @@ impl DefIdVisitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> { /// warnings instead of hard errors when the erroneous node is not in this old set. /////////////////////////////////////////////////////////////////////////////// -struct ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx: 'a> { +struct ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, access_levels: &'a AccessLevels, in_variant: bool, @@ -1210,7 +1210,7 @@ struct ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx: 'a> { old_error_set: HirIdSet, } -struct ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b: 'a, 'tcx: 'b> { +struct ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> { inner: &'a ObsoleteVisiblePrivateTypesVisitor<'b, 'tcx>, /// Whether the type refers to private types. contains_private: bool, @@ -1651,7 +1651,7 @@ impl DefIdVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'tcx> { } } -struct PrivateItemsInPublicInterfacesVisitor<'a, 'tcx: 'a> { +struct PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, has_pub_restricted: bool, old_error_set: &'a HirIdSet, diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index e3cd2948d7a..18ed91689ec 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -930,7 +930,7 @@ impl<'a> Resolver<'a> { } } -pub struct BuildReducedGraphVisitor<'a, 'b: 'a> { +pub struct BuildReducedGraphVisitor<'a, 'b> { pub resolver: &'a mut Resolver<'b>, pub current_legacy_scope: LegacyScope<'b>, pub expansion: Mark, diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 3b6179f7855..4fee15c59b3 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -48,7 +48,7 @@ impl<'a> UnusedImport<'a> { } } -struct UnusedImportCheckVisitor<'a, 'b: 'a> { +struct UnusedImportCheckVisitor<'a, 'b> { resolver: &'a mut Resolver<'b>, /// All the (so far) unused imports, grouped path list unused_imports: NodeMap>, diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index d8292eebce7..e93a2315ca3 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -441,7 +441,7 @@ impl<'a> Resolver<'a> { } } -impl<'a, 'b:'a> ImportResolver<'a, 'b> { +impl<'a, 'b> ImportResolver<'a, 'b> { /// Adds suggestions for a path that cannot be resolved. pub(crate) fn make_path_suggestion( &mut self, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 7f05e0f477c..a127c960685 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1735,7 +1735,7 @@ impl<'a> ResolverArenas<'a> { } } -impl<'a, 'b: 'a> ty::DefIdTree for &'a Resolver<'b> { +impl<'a, 'b> ty::DefIdTree for &'a Resolver<'b> { fn parent(self, id: DefId) -> Option { match id.krate { LOCAL_CRATE => self.definitions.def_key(id.index).parent, diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 2369bddf4f7..47ed3d684b2 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -132,7 +132,7 @@ impl<'a> base::Resolver for Resolver<'a> { } fn resolve_dollar_crates(&mut self, fragment: &AstFragment) { - struct ResolveDollarCrates<'a, 'b: 'a> { + struct ResolveDollarCrates<'a, 'b> { resolver: &'a mut Resolver<'b> } impl<'a> Visitor<'a> for ResolveDollarCrates<'a, '_> { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index d24d8f8c2b5..f69849bb4a9 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -644,30 +644,30 @@ struct UnresolvedImportError { suggestion: Option, } -pub struct ImportResolver<'a, 'b: 'a> { +pub struct ImportResolver<'a, 'b> { pub resolver: &'a mut Resolver<'b>, } -impl<'a, 'b: 'a> std::ops::Deref for ImportResolver<'a, 'b> { +impl<'a, 'b> std::ops::Deref for ImportResolver<'a, 'b> { type Target = Resolver<'b>; fn deref(&self) -> &Resolver<'b> { self.resolver } } -impl<'a, 'b: 'a> std::ops::DerefMut for ImportResolver<'a, 'b> { +impl<'a, 'b> std::ops::DerefMut for ImportResolver<'a, 'b> { fn deref_mut(&mut self) -> &mut Resolver<'b> { self.resolver } } -impl<'a, 'b: 'a> ty::DefIdTree for &'a ImportResolver<'a, 'b> { +impl<'a, 'b> ty::DefIdTree for &'a ImportResolver<'a, 'b> { fn parent(self, id: DefId) -> Option { self.resolver.parent(id) } } -impl<'a, 'b:'a> ImportResolver<'a, 'b> { +impl<'a, 'b> ImportResolver<'a, 'b> { // Import resolution // // This is a fixed-point algorithm. We resolve imports until our efforts diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index f9dd4436434..a7f46e87683 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -75,7 +75,7 @@ macro_rules! access_from_vis { }; } -pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput> { +pub struct DumpVisitor<'l, 'tcx, 'll, O: DumpOutput> { save_ctxt: SaveContext<'l, 'tcx>, tcx: TyCtxt<'tcx>, dumper: &'ll mut JsonDumper, @@ -92,7 +92,7 @@ pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput> { // macro_calls: FxHashSet, } -impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { +impl<'l, 'tcx, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { pub fn new( save_ctxt: SaveContext<'l, 'tcx>, dumper: &'ll mut JsonDumper, @@ -1311,7 +1311,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { } } -impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, O> { +impl<'l, 'tcx, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, O> { fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, attrs: &[ast::Attribute], id: NodeId) { // Since we handle explicit modules ourselves in visit_item, this should // only get called for the root module of a crate. diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index fb9f872880e..4882a4240c8 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -51,7 +51,7 @@ use rls_data::config::Config; use log::{debug, error, info}; -pub struct SaveContext<'l, 'tcx: 'l> { +pub struct SaveContext<'l, 'tcx> { tcx: TyCtxt<'tcx>, tables: &'l ty::TypeckTables<'tcx>, access_levels: &'l AccessLevels, @@ -67,7 +67,7 @@ pub enum Data { RelationData(Relation, Impl), } -impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { +impl<'l, 'tcx> SaveContext<'l, 'tcx> { fn span_from_span(&self, span: Span) -> SpanData { use rls_span::{Column, Row}; @@ -960,7 +960,7 @@ impl<'l> PathCollector<'l> { } } -impl<'l, 'a: 'l> Visitor<'a> for PathCollector<'l> { +impl<'l, 'a> Visitor<'a> for PathCollector<'l> { fn visit_pat(&mut self, p: &'a ast::Pat) { match p.node { PatKind::Struct(ref path, ..) => { diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index 2b678919ce4..bbb0825ee08 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -56,7 +56,7 @@ crate struct ChalkContext<'tcx> { } #[derive(Copy, Clone)] -crate struct ChalkInferenceContext<'cx, 'tcx: 'cx> { +crate struct ChalkInferenceContext<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, } diff --git a/src/librustc_traits/chalk_context/resolvent_ops.rs b/src/librustc_traits/chalk_context/resolvent_ops.rs index 1e8b02659dc..59c01b8b1b7 100644 --- a/src/librustc_traits/chalk_context/resolvent_ops.rs +++ b/src/librustc_traits/chalk_context/resolvent_ops.rs @@ -139,7 +139,7 @@ impl context::ResolventOps, ChalkArenas<'tcx>> } } -struct AnswerSubstitutor<'cx, 'tcx: 'cx> { +struct AnswerSubstitutor<'cx, 'tcx> { infcx: &'cx InferCtxt<'cx, 'tcx>, environment: Environment<'tcx>, answer_subst: CanonicalVarValues<'tcx>, diff --git a/src/librustc_traits/chalk_context/unify.rs b/src/librustc_traits/chalk_context/unify.rs index d66faa92336..1f909032441 100644 --- a/src/librustc_traits/chalk_context/unify.rs +++ b/src/librustc_traits/chalk_context/unify.rs @@ -42,7 +42,7 @@ crate fn unify<'me, 'tcx, T: Relate<'tcx>>( }) } -struct ChalkTypeRelatingDelegate<'me, 'tcx: 'me> { +struct ChalkTypeRelatingDelegate<'me, 'tcx> { infcx: &'me InferCtxt<'me, 'tcx>, environment: Environment<'tcx>, goals: Vec>>, diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs index dcbb0dffba8..cb30eba5b05 100644 --- a/src/librustc_traits/type_op.rs +++ b/src/librustc_traits/type_op.rs @@ -56,7 +56,7 @@ fn type_op_ascribe_user_type<'tcx>( }) } -struct AscribeUserTypeCx<'me, 'tcx: 'me> { +struct AscribeUserTypeCx<'me, 'tcx> { infcx: &'me InferCtxt<'me, 'tcx>, param_env: ParamEnv<'tcx>, fulfill_cx: &'me mut dyn TraitEngine<'tcx>, diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index dc4969d7ad2..ecdf28e5d7f 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -20,7 +20,7 @@ enum AutoderefKind { Overloaded, } -pub struct Autoderef<'a, 'tcx: 'a> { +pub struct Autoderef<'a, 'tcx> { infcx: &'a InferCtxt<'a, 'tcx>, body_id: hir::HirId, param_env: ty::ParamEnv<'tcx>, diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 5f9aa5fbabe..ac2dcbadad8 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -12,7 +12,7 @@ use syntax_pos::Span; use super::FnCtxt; use crate::util::nodemap::FxHashMap; -struct InteriorVisitor<'a, 'tcx: 'a> { +struct InteriorVisitor<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, types: FxHashMap, usize>, region_scope_tree: &'tcx region::ScopeTree, diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 29b4fee138e..5943302c708 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -787,7 +787,7 @@ fn compute_all_traits<'tcx>(tcx: TyCtxt<'tcx>) -> Vec { // Crate-local: - struct Visitor<'a, 'tcx: 'a> { + struct Visitor<'a, 'tcx> { map: &'a hir_map::Map<'tcx>, traits: &'a mut Vec, } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 10bfe9e034d..864f19933a5 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -160,7 +160,7 @@ pub struct LocalTy<'tcx> { /// A wrapper for `InferCtxt`'s `in_progress_tables` field. #[derive(Copy, Clone)] -struct MaybeInProgressTables<'a, 'tcx: 'a> { +struct MaybeInProgressTables<'a, 'tcx> { maybe_tables: Option<&'a RefCell>>, } @@ -193,7 +193,7 @@ impl<'a, 'tcx> MaybeInProgressTables<'a, 'tcx> { /// Here, the function `foo()` and the closure passed to /// `bar()` will each have their own `FnCtxt`, but they will /// share the inherited fields. -pub struct Inherited<'a, 'tcx: 'a> { +pub struct Inherited<'a, 'tcx> { infcx: InferCtxt<'a, 'tcx>, tables: MaybeInProgressTables<'a, 'tcx>, @@ -512,7 +512,7 @@ impl<'tcx> EnclosingBreakables<'tcx> { } } -pub struct FnCtxt<'a, 'tcx: 'a> { +pub struct FnCtxt<'a, 'tcx> { body_id: hir::HirId, /// The parameter environment used for proving trait obligations @@ -919,7 +919,7 @@ fn check_abi<'tcx>(tcx: TyCtxt<'tcx>, span: Span, abi: Abi) { } } -struct GatherLocalsVisitor<'a, 'tcx: 'a> { +struct GatherLocalsVisitor<'a, 'tcx> { fcx: &'a FnCtxt<'a, 'tcx>, parent_id: hir::HirId, } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index ffc323f28b6..6a95dec1c81 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -96,7 +96,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // there, it applies a few ad-hoc checks that were not convenient to // do elsewhere. -struct WritebackCx<'cx, 'tcx: 'cx> { +struct WritebackCx<'cx, 'tcx> { fcx: &'cx FnCtxt<'cx, 'tcx>, tables: ty::TypeckTables<'tcx>, @@ -787,7 +787,7 @@ impl Locatable for hir::HirId { // The Resolver. This is the type folding engine that detects // unresolved types and so forth. -struct Resolver<'cx, 'tcx: 'cx> { +struct Resolver<'cx, 'tcx> { tcx: TyCtxt<'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>, span: &'cx dyn Locatable, diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index dda86778f27..8f89a77bd1a 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -194,7 +194,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'tcx>) { } } -struct CollectExternCrateVisitor<'a, 'tcx: 'a> { +struct CollectExternCrateVisitor<'a, 'tcx> { tcx: TyCtxt<'tcx>, crates_to_lint: &'a mut Vec, } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 5606d9c0ce8..70deca9623b 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1786,7 +1786,7 @@ fn impl_polarity<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> hir::ImplPolarity { /// the lifetimes that are declared. For fns or methods, we have to /// screen out those that do not appear in any where-clauses etc using /// `resolve_lifetime::early_bound_lifetimes`. -fn early_bound_lifetimes_from_generics<'a, 'tcx: 'a>( +fn early_bound_lifetimes_from_generics<'a, 'tcx>( tcx: TyCtxt<'tcx>, generics: &'a hir::Generics, ) -> impl Iterator + Captures<'tcx> { diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index a2f9a2bb50a..1c2bb8c2f0b 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -43,7 +43,7 @@ pub fn infer_predicates<'tcx>( global_inferred_outlives } -pub struct InferVisitor<'cx, 'tcx: 'cx> { +pub struct InferVisitor<'cx, 'tcx> { tcx: TyCtxt<'tcx>, global_inferred_outlives: &'cx mut FxHashMap>, predicates_added: &'cx mut bool, diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 59213ac3c13..36f0dbcd2fc 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -12,7 +12,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use super::terms::*; use super::terms::VarianceTerm::*; -pub struct ConstraintContext<'a, 'tcx: 'a> { +pub struct ConstraintContext<'a, 'tcx> { pub terms_cx: TermsContext<'a, 'tcx>, // These are pointers to common `ConstantTerm` instances diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index 8edf3c52ccc..3851b918c48 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -14,7 +14,7 @@ use super::terms::*; use super::terms::VarianceTerm::*; use super::xform::*; -struct SolveContext<'a, 'tcx: 'a> { +struct SolveContext<'a, 'tcx> { terms_cx: TermsContext<'a, 'tcx>, constraints: Vec>, diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index 99f87ccb6f6..3f6eadeac33 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -47,7 +47,7 @@ impl<'a> fmt::Debug for VarianceTerm<'a> { // The first pass over the crate simply builds up the set of inferreds. -pub struct TermsContext<'a, 'tcx: 'a> { +pub struct TermsContext<'a, 'tcx> { pub tcx: TyCtxt<'tcx>, pub arena: &'a TypedArena>, diff --git a/src/librustdoc/passes/check_code_block_syntax.rs b/src/librustdoc/passes/check_code_block_syntax.rs index 6d51278b4e5..f6ab1290da3 100644 --- a/src/librustdoc/passes/check_code_block_syntax.rs +++ b/src/librustdoc/passes/check_code_block_syntax.rs @@ -20,7 +20,7 @@ pub fn check_code_block_syntax(krate: clean::Crate, cx: &DocContext<'_>) -> clea SyntaxChecker { cx }.fold_crate(krate) } -struct SyntaxChecker<'a, 'tcx: 'a> { +struct SyntaxChecker<'a, 'tcx> { cx: &'a DocContext<'tcx>, } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 9a9fd941240..ddce5cab1eb 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -878,7 +878,7 @@ impl Tester for Collector { } } -struct HirCollector<'a, 'hir: 'a> { +struct HirCollector<'a, 'hir> { sess: &'a session::Session, collector: &'a mut Collector, map: &'a hir::map::Map<'hir>, diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 8f926e6dd29..2c3bea80e34 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2502,7 +2502,7 @@ impl ToJson for Option { } } -struct FormatShim<'a, 'b: 'a> { +struct FormatShim<'a, 'b> { inner: &'a mut fmt::Formatter<'b>, } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 3fa96c60bff..d433e6c5a89 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -242,7 +242,7 @@ impl Invocation { } } -pub struct MacroExpander<'a, 'b:'a> { +pub struct MacroExpander<'a, 'b> { pub cx: &'a mut ExtCtxt<'b>, monotonic: bool, // cf. `cx.monotonic_expander()` } @@ -1031,7 +1031,7 @@ impl<'a> Parser<'a> { } } -struct InvocationCollector<'a, 'b: 'a> { +struct InvocationCollector<'a, 'b> { cx: &'a mut ExtCtxt<'b>, cfg: StripUnconfigured<'a>, invocations: Vec, diff --git a/src/libsyntax/ext/placeholders.rs b/src/libsyntax/ext/placeholders.rs index c56c156182b..b2b8bfb09b4 100644 --- a/src/libsyntax/ext/placeholders.rs +++ b/src/libsyntax/ext/placeholders.rs @@ -69,7 +69,7 @@ pub fn placeholder(kind: AstFragmentKind, id: ast::NodeId) -> AstFragment { } } -pub struct PlaceholderExpander<'a, 'b: 'a> { +pub struct PlaceholderExpander<'a, 'b> { expanded_fragments: FxHashMap, cx: &'a mut ExtCtxt<'b>, monotonic: bool, diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 4758b6a50e5..d5da4c920bc 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -156,7 +156,7 @@ type NamedMatchVec = SmallVec<[NamedMatch; 4]>; /// all the elements in that `SmallVec` strictly outlive the root stack slot /// lifetime. By separating `'tt` from `'root`, we can show that. #[derive(Clone)] -struct MatcherPos<'root, 'tt: 'root> { +struct MatcherPos<'root, 'tt> { /// The token or sequence of tokens that make up the matcher top_elts: TokenTreeOrTokenTreeSlice<'tt>, @@ -233,7 +233,7 @@ impl<'root, 'tt> MatcherPos<'root, 'tt> { // Therefore, the initial MatcherPos is always allocated on the stack, // subsequent ones (of which there aren't that many) are allocated on the heap, // and this type is used to encapsulate both cases. -enum MatcherPosHandle<'root, 'tt: 'root> { +enum MatcherPosHandle<'root, 'tt> { Ref(&'root mut MatcherPos<'root, 'tt>), Box(Box>), } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 8b719b5477c..3edf7726ec6 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -346,7 +346,7 @@ fn find_type_parameters(ty: &ast::Ty, -> Vec> { use syntax::visit; - struct Visitor<'a, 'b: 'a> { + struct Visitor<'a, 'b> { cx: &'a ExtCtxt<'b>, span: Span, ty_param_names: &'a [ast::Name], diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index f44a6e7efa4..a5f96559ca8 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -31,7 +31,7 @@ enum Position { Named(Symbol), } -struct Context<'a, 'b: 'a> { +struct Context<'a, 'b> { ecx: &'a mut ExtCtxt<'b>, /// The macro's call site. References to unstable formatting internals must /// use this span to pass the stability checker. -- cgit 1.4.1-3-g733a5 From 0b58bb32f66f4ec5f00683293093d94d8fb1aada Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 5 Jun 2019 17:59:37 +0300 Subject: Support `cfg` and `cfg_attr` on generic parameters --- src/libsyntax/config.rs | 20 ++----- src/libsyntax/ext/expand.rs | 6 +- .../conditional-compilation/cfg-generic-params.rs | 38 +++++++++++++ .../cfg-generic-params.stderr | 66 ++++++++++++++++++++++ src/test/ui/issues/issue-51279.rs | 27 --------- src/test/ui/issues/issue-51279.stderr | 60 -------------------- 6 files changed, 111 insertions(+), 106 deletions(-) create mode 100644 src/test/ui/conditional-compilation/cfg-generic-params.rs create mode 100644 src/test/ui/conditional-compilation/cfg-generic-params.stderr delete mode 100644 src/test/ui/issues/issue-51279.rs delete mode 100644 src/test/ui/issues/issue-51279.stderr (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 1cc13ac7878..3b42e1de614 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -240,6 +240,10 @@ impl<'a> StripUnconfigured<'a> { items.flat_map_in_place(|item| self.configure(item)); } + pub fn configure_generic_params(&mut self, params: &mut Vec) { + params.flat_map_in_place(|param| self.configure(param)); + } + fn configure_variant_data(&mut self, vdata: &mut ast::VariantData) { match vdata { ast::VariantData::Struct(fields, ..) | ast::VariantData::Tuple(fields, _) => @@ -301,22 +305,6 @@ 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)); } - - /// Denies `#[cfg]` on generic parameters until we decide what to do with it. - /// See issue #51279. - pub fn disallow_cfg_on_generic_param(&mut self, param: &ast::GenericParam) { - for attr in param.attrs() { - let offending_attr = if attr.check_name(sym::cfg) { - "cfg" - } else if attr.check_name(sym::cfg_attr) { - "cfg_attr" - } else { - continue; - }; - let msg = format!("#[{}] cannot be applied on a generic parameter", offending_attr); - self.sess.span_diagnostic.span_err(attr.span, &msg); - } - } } impl<'a> MutVisitor for StripUnconfigured<'a> { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d433e6c5a89..a71d1d503ca 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1439,9 +1439,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } } - fn visit_generic_param(&mut self, param: &mut ast::GenericParam) { - self.cfg.disallow_cfg_on_generic_param(¶m); - noop_visit_generic_param(param, self) + fn visit_generic_params(&mut self, params: &mut Vec) { + self.cfg.configure_generic_params(params); + noop_visit_generic_params(params, self); } fn visit_attribute(&mut self, at: &mut ast::Attribute) { diff --git a/src/test/ui/conditional-compilation/cfg-generic-params.rs b/src/test/ui/conditional-compilation/cfg-generic-params.rs new file mode 100644 index 00000000000..d80d3ea7b7f --- /dev/null +++ b/src/test/ui/conditional-compilation/cfg-generic-params.rs @@ -0,0 +1,38 @@ +// compile-flags:--cfg yes + +fn f_lt<#[cfg(yes)] 'a: 'a, #[cfg(no)] T>() {} +fn f_ty<#[cfg(no)] 'a: 'a, #[cfg(yes)] T>() {} + +type FnGood = for<#[cfg(yes)] 'a, #[cfg(no)] T> fn(); // OK +type FnBad = for<#[cfg(no)] 'a, #[cfg(yes)] T> fn(); +//~^ ERROR only lifetime parameters can be used in this context + +type PolyGood = dyn for<#[cfg(yes)] 'a, #[cfg(no)] T> Copy; // OK +type PolyBad = dyn for<#[cfg(no)] 'a, #[cfg(yes)] T> Copy; +//~^ ERROR only lifetime parameters can be used in this context + +struct WhereGood where for<#[cfg(yes)] 'a, #[cfg(no)] T> u8: Copy; // OK +struct WhereBad where for<#[cfg(no)] 'a, #[cfg(yes)] T> u8: Copy; +//~^ ERROR only lifetime parameters can be used in this context + +fn f_lt_no<#[cfg_attr(no, unknown)] 'a>() {} // OK +fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} //~ ERROR attribute `unknown` is currently unknown +fn f_ty_no<#[cfg_attr(no, unknown)] T>() {} // OK +fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} //~ ERROR attribute `unknown` is currently unknown + +type FnNo = for<#[cfg_attr(no, unknown)] 'a> fn(); // OK +type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn(); +//~^ ERROR attribute `unknown` is currently unknown + +type PolyNo = dyn for<#[cfg_attr(no, unknown)] 'a> Copy; // OK +type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy; +//~^ ERROR attribute `unknown` is currently unknown + +struct WhereNo where for<#[cfg_attr(no, unknown)] 'a> u8: Copy; // OK +struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy; +//~^ ERROR attribute `unknown` is currently unknown + +fn main() { + f_lt::<'static>(); + f_ty::(); +} diff --git a/src/test/ui/conditional-compilation/cfg-generic-params.stderr b/src/test/ui/conditional-compilation/cfg-generic-params.stderr new file mode 100644 index 00000000000..40ca44d9db5 --- /dev/null +++ b/src/test/ui/conditional-compilation/cfg-generic-params.stderr @@ -0,0 +1,66 @@ +error: only lifetime parameters can be used in this context + --> $DIR/cfg-generic-params.rs:7:45 + | +LL | type FnBad = for<#[cfg(no)] 'a, #[cfg(yes)] T> fn(); + | ^ + +error: only lifetime parameters can be used in this context + --> $DIR/cfg-generic-params.rs:11:51 + | +LL | type PolyBad = dyn for<#[cfg(no)] 'a, #[cfg(yes)] T> Copy; + | ^ + +error: only lifetime parameters can be used in this context + --> $DIR/cfg-generic-params.rs:15:54 + | +LL | struct WhereBad where for<#[cfg(no)] 'a, #[cfg(yes)] T> u8: Copy; + | ^ + +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/cfg-generic-params.rs:19:29 + | +LL | fn f_lt_yes<#[cfg_attr(yes, unknown)] 'a>() {} + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/cfg-generic-params.rs:21:29 + | +LL | fn f_ty_yes<#[cfg_attr(yes, unknown)] T>() {} + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/cfg-generic-params.rs:24:34 + | +LL | type FnYes = for<#[cfg_attr(yes, unknown)] 'a> fn(); + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/cfg-generic-params.rs:28:40 + | +LL | type PolyYes = dyn for<#[cfg_attr(yes, unknown)] 'a> Copy; + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/cfg-generic-params.rs:32:43 + | +LL | struct WhereYes where for<#[cfg_attr(yes, unknown)] 'a> u8: Copy; + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-51279.rs b/src/test/ui/issues/issue-51279.rs deleted file mode 100644 index f8f3626caab..00000000000 --- a/src/test/ui/issues/issue-51279.rs +++ /dev/null @@ -1,27 +0,0 @@ -pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); -//~^ ERROR #[cfg] cannot be applied on a generic parameter -//~^^ ERROR #[cfg] cannot be applied on a generic parameter - -impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} -//~^ ERROR #[cfg] cannot be applied on a generic parameter -//~^^ ERROR #[cfg] cannot be applied on a generic parameter - -pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} -//~^ ERROR #[cfg] cannot be applied on a generic parameter -//~^^ ERROR #[cfg] cannot be applied on a generic parameter - -#[cfg(none)] -pub struct Y<#[cfg(none)] T>(T); // shouldn't care when the entire item is stripped out - -struct M(*const T); - -impl<#[cfg_attr(none, may_dangle)] T> Drop for M { - //~^ ERROR #[cfg_attr] cannot be applied on a generic parameter - fn drop(&mut self) {} -} - -type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; -//~^ ERROR #[cfg] cannot be applied on a generic parameter -//~| ERROR attribute `ignored` is currently unknown to the compiler - -fn main() {} diff --git a/src/test/ui/issues/issue-51279.stderr b/src/test/ui/issues/issue-51279.stderr deleted file mode 100644 index 9dd4a9f2381..00000000000 --- a/src/test/ui/issues/issue-51279.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error: #[cfg] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:1:14 - | -LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); - | ^^^^^^^^^^^^ - -error: #[cfg] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:1:31 - | -LL | pub struct X<#[cfg(none)] 'a, #[cfg(none)] T>(&'a T); - | ^^^^^^^^^^^^ - -error: #[cfg] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:5:6 - | -LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} - | ^^^^^^^^^^^^ - -error: #[cfg] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:5:23 - | -LL | impl<#[cfg(none)] 'a, #[cfg(none)] T> X<'a, T> {} - | ^^^^^^^^^^^^ - -error: #[cfg] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:9:10 - | -LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} - | ^^^^^^^^^^^^ - -error: #[cfg] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:9:27 - | -LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} - | ^^^^^^^^^^^^ - -error: #[cfg_attr] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:18:6 - | -LL | impl<#[cfg_attr(none, may_dangle)] T> Drop for M { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: #[cfg] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:23:23 - | -LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; - | ^^^^^^^^^^^^ - -error[E0658]: The attribute `ignored` is currently unknown to the compiler and may have meaning added to it in the future - --> $DIR/issue-51279.rs:23:8 - | -LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; - | ^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/29642 - = help: add #![feature(custom_attribute)] to the crate attributes to enable - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0658`. -- cgit 1.4.1-3-g733a5