Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #61713

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a4a07e0
Replaced linear token counting macros with optimized implementation
tobia Apr 1, 2019
97a5173
syntax: Remove `SyntaxExtension::IdentTT` and `IdentMacroExpander`
petrochenkov Jun 6, 2019
4419af8
Remove `SyntaxExtension::MultiDecorator` and `MultiItemDecorator`
petrochenkov Jun 6, 2019
cc17dbb
syntax: Use `MultiItemModifier` for built-in derives
petrochenkov Jun 6, 2019
fa48a02
Remove `SyntaxExtension::DeclMacro`
petrochenkov Jun 6, 2019
a9397fd
syntax: Improve documentation of `SyntaxExtension`
petrochenkov Jun 6, 2019
48d2c0b
syntax: Rename variants of `SyntaxExtension` for consistency
petrochenkov Jun 6, 2019
f1867c5
Rename `infer_types` to `infer_args`
varkor Jun 7, 2019
5377dea
Fix issue with const arg inference
varkor Jun 6, 2019
a0e3e9a
Refactor `ty_infer` and `re_infer`
varkor Jun 6, 2019
647b4a4
Add test for const generics struct constructor
varkor Jun 6, 2019
7bb0a16
Add test for deriving Debug for const generics
varkor Jun 6, 2019
f11e6f7
Fix issue with path segment lowering with const args
varkor Jun 6, 2019
00f8f82
some more comments for const_qualif
RalfJung Jun 3, 2019
5aaf72f
replace some mode comparisons by more readable function call, rename …
RalfJung Jun 3, 2019
7e96bd0
avoid 'const-context' terminology
RalfJung Jun 6, 2019
4dbd279
const-correctness might be confusing for C++ people
RalfJung Jun 6, 2019
38c7f3e
comments
RalfJung Jun 6, 2019
1d04514
submodules: update clippy from 71be6f62 to c0dbd34b
matthiaskrgr Jun 9, 2019
35b5f43
Special-case literals in `parse_bottom_expr`.
nnethercote Jun 7, 2019
cdfbf14
Rollup merge of #59600 - tobia:master, r=pnkfelix
Centril Jun 10, 2019
02d8876
Rollup merge of #61492 - RalfJung:const-qualif-comments, r=eddyb
Centril Jun 10, 2019
050262a
Rollup merge of #61570 - varkor:infer-const-arg, r=eddyb
Centril Jun 10, 2019
78c326f
Rollup merge of #61606 - petrochenkov:legclean, r=pnkfelix
Centril Jun 10, 2019
965e75a
Rollup merge of #61612 - nnethercote:improve-parse_bottom_expr, r=pet…
Centril Jun 10, 2019
2679947
Rollup merge of #61697 - matthiaskrgr:submodule_upd, r=Manishearth
Centril Jun 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2168,7 +2168,7 @@ impl<'a> LoweringContext<'a> {
itctx: ImplTraitContext<'_>,
explicit_owner: Option<NodeId>,
) -> hir::PathSegment {
let (mut generic_args, infer_types) = if let Some(ref generic_args) = segment.args {
let (mut generic_args, infer_args) = if let Some(ref generic_args) = segment.args {
let msg = "parenthesized type parameters may only be used with a `Fn` trait";
match **generic_args {
GenericArgs::AngleBracketed(ref data) => {
Expand Down Expand Up @@ -2230,17 +2230,17 @@ impl<'a> LoweringContext<'a> {
.collect();
if expected_lifetimes > 0 && param_mode == ParamMode::Explicit {
let anon_lt_suggestion = vec!["'_"; expected_lifetimes].join(", ");
let no_ty_args = generic_args.args.len() == expected_lifetimes;
let no_non_lt_args = generic_args.args.len() == expected_lifetimes;
let no_bindings = generic_args.bindings.is_empty();
let (incl_angl_brckt, insertion_span, suggestion) = if no_ty_args && no_bindings {
let (incl_angl_brckt, insertion_sp, suggestion) = if no_non_lt_args && no_bindings {
// If there are no (non-implicit) generic args or associated type
// bindings, our suggestion includes the angle brackets.
(true, path_span.shrink_to_hi(), format!("<{}>", anon_lt_suggestion))
} else {
// Otherwise (sorry, this is kind of gross) we need to infer the
// place to splice in the `'_, ` from the generics that do exist.
let first_generic_span = first_generic_span
.expect("already checked that type args or bindings exist");
.expect("already checked that non-lifetime args or bindings exist");
(false, first_generic_span.shrink_to_lo(), format!("{}, ", anon_lt_suggestion))
};
match self.anonymous_lifetime_mode {
Expand All @@ -2263,7 +2263,7 @@ impl<'a> LoweringContext<'a> {
expected_lifetimes,
path_span,
incl_angl_brckt,
insertion_span,
insertion_sp,
suggestion,
);
err.emit();
Expand All @@ -2280,7 +2280,7 @@ impl<'a> LoweringContext<'a> {
expected_lifetimes,
path_span,
incl_angl_brckt,
insertion_span,
insertion_sp,
suggestion,
)
);
Expand All @@ -2305,7 +2305,7 @@ impl<'a> LoweringContext<'a> {
Some(id),
Some(self.lower_res(res)),
generic_args,
infer_types,
infer_args,
)
}

Expand All @@ -2316,9 +2316,10 @@ impl<'a> LoweringContext<'a> {
mut itctx: ImplTraitContext<'_>,
) -> (hir::GenericArgs, bool) {
let &AngleBracketedArgs { ref args, ref constraints, .. } = data;
let has_types = args.iter().any(|arg| match arg {
let has_non_lt_args = args.iter().any(|arg| match arg {
ast::GenericArg::Lifetime(_) => false,
ast::GenericArg::Type(_) => true,
_ => false,
ast::GenericArg::Const(_) => true,
});
(
hir::GenericArgs {
Expand All @@ -2328,7 +2329,7 @@ impl<'a> LoweringContext<'a> {
.collect(),
parenthesized: false,
},
!has_types && param_mode == ParamMode::Optional
!has_non_lt_args && param_mode == ParamMode::Optional
)
}

Expand Down
12 changes: 10 additions & 2 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,17 @@ impl DefPathData {
}
}

/// Evaluates to the number of tokens passed to it.
///
/// Logarithmic counting: every one or two recursive expansions, the number of
/// tokens to count is divided by two, instead of being reduced by one.
/// Therefore, the recursion depth is the binary logarithm of the number of
/// tokens to count, and the expanded tree is likewise very small.
macro_rules! count {
() => (0usize);
( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));
() => (0usize);
($one:tt) => (1usize);
($($pairs:tt $_p:tt)*) => (count!($($pairs)*) << 1usize);
($odd:tt $($rest:tt)*) => (count!($($rest)*) | 1usize);
}

// We define the GlobalMetaDataKind enum with this macro because we want to
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub struct PathSegment {
/// This only applies to expression and pattern paths, and
/// out of those only the segments with no type parameters
/// to begin with, e.g., `Vec::new` is `<Vec<..>>::new::<..>`.
pub infer_types: bool,
pub infer_args: bool,
}

impl PathSegment {
Expand All @@ -358,7 +358,7 @@ impl PathSegment {
ident,
hir_id: None,
res: None,
infer_types: true,
infer_args: true,
args: None,
}
}
Expand All @@ -368,13 +368,13 @@ impl PathSegment {
hir_id: Option<HirId>,
res: Option<Res>,
args: GenericArgs,
infer_types: bool,
infer_args: bool,
) -> Self {
PathSegment {
ident,
hir_id,
res,
infer_types,
infer_args,
args: if args.is_empty() {
None
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ impl<'a> State<'a> {

segment.with_generic_args(|generic_args| {
if !generic_args.args.is_empty() || !generic_args.bindings.is_empty() {
return self.print_generic_args(&generic_args, segment.infer_types, true);
return self.print_generic_args(&generic_args, segment.infer_args, true);
}
Ok(())
})?;
Expand Down Expand Up @@ -1561,7 +1561,7 @@ impl<'a> State<'a> {
if segment.ident.name != kw::PathRoot {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args, segment.infer_types,
self.print_generic_args(generic_args, segment.infer_args,
colons_before_params)
})?;
}
Expand All @@ -1574,7 +1574,7 @@ impl<'a> State<'a> {
if segment.ident.name != kw::PathRoot {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args, segment.infer_types, false)
self.print_generic_args(generic_args, segment.infer_args, false)
})?;
}
Ok(())
Expand Down Expand Up @@ -1602,7 +1602,7 @@ impl<'a> State<'a> {
self.print_ident(segment.ident)?;
segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
segment.infer_types,
segment.infer_args,
colons_before_params)
})?;
}
Expand All @@ -1614,7 +1614,7 @@ impl<'a> State<'a> {
self.print_ident(item_segment.ident)?;
item_segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
item_segment.infer_types,
item_segment.infer_args,
colons_before_params)
})
}
Expand All @@ -1626,7 +1626,7 @@ impl<'a> State<'a> {
self.print_ident(item_segment.ident)?;
item_segment.with_generic_args(|generic_args| {
self.print_generic_args(generic_args,
item_segment.infer_types,
item_segment.infer_args,
colons_before_params)
})
}
Expand All @@ -1635,7 +1635,7 @@ impl<'a> State<'a> {

fn print_generic_args(&mut self,
generic_args: &hir::GenericArgs,
infer_types: bool,
infer_args: bool,
colons_before_params: bool)
-> io::Result<()> {
if generic_args.parenthesized {
Expand Down Expand Up @@ -1681,7 +1681,7 @@ impl<'a> State<'a> {

// FIXME(eddyb): this would leak into error messages (e.g.,
// "non-exhaustive patterns: `Some::<..>(_)` not covered").
if infer_types && false {
if infer_args && false {
start_or_comma(self)?;
self.s.word("..")?;
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl<'a> CrateLoader<'a> {
match decl {
ProcMacro::CustomDerive { trait_name, attributes, client } => {
let attrs = attributes.iter().cloned().map(Symbol::intern).collect::<Vec<_>>();
(trait_name, SyntaxExtension::ProcMacroDerive(
(trait_name, SyntaxExtension::Derive(
Box::new(ProcMacroDerive {
client,
attrs: attrs.clone(),
Expand All @@ -624,13 +624,13 @@ impl<'a> CrateLoader<'a> {
))
}
ProcMacro::Attr { name, client } => {
(name, SyntaxExtension::AttrProcMacro(
(name, SyntaxExtension::Attr(
Box::new(AttrProcMacro { client }),
root.edition,
))
}
ProcMacro::Bang { name, client } => {
(name, SyntaxExtension::ProcMacro {
(name, SyntaxExtension::Bang {
expander: Box::new(BangProcMacro { client }),
allow_internal_unstable: None,
edition: root.edition,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl cstore::CStore {
use syntax_ext::proc_macro_impl::BangProcMacro;

let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
let ext = SyntaxExtension::ProcMacro {
let ext = SyntaxExtension::Bang {
expander: Box::new(BangProcMacro { client }),
allow_internal_unstable: Some(vec![sym::proc_macro_def_site].into()),
edition: data.root.edition,
Expand Down
Loading