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 8 pull requests #65396

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a185061
Sort long error code explanation by error code
GuillaumeGomez Oct 10, 2019
019fba8
Uncomment E0386 to let users have access to its old definition
GuillaumeGomez Oct 10, 2019
06a02b5
Unification and cleanup of librustc_mir error codes
GuillaumeGomez Oct 10, 2019
e0ef776
Add long error explanation for E0697
JohnTitor Oct 8, 2019
2ae5e34
Print lifetimes with backticks
JohnTitor Oct 10, 2019
c6cc29d
Apply suggestion
JohnTitor Oct 13, 2019
d131abe
ast: don't use pprust in Debug
Centril Oct 8, 2019
742ec4b
ast: remove implicit pprust dependency via Display.
Centril Oct 8, 2019
ab8105e
tokenstream: don't depend on pprust
Centril Oct 8, 2019
4a0c487
syntax: consolidate function parsing in `item.rs`
Centril Oct 11, 2019
9d766ed
refactor session::config::build_session_options_and_crate_config
Centril Oct 11, 2019
42f32f0
token: extract Nonterminal::to_tokenstream to parser.
Centril Oct 9, 2019
1899432
lowering: don't rely on parser directly.
Centril Oct 13, 2019
07e946c
lowering: connect to parser via function pointer instead
Centril Oct 13, 2019
5c8fdc1
Add test for issue-44153
JohnTitor Oct 14, 2019
6323180
Add test for issue-47486
JohnTitor Oct 14, 2019
f653db9
Add test for issue-48010
JohnTitor Oct 14, 2019
88a495c
Add test for issue-48027
JohnTitor Oct 14, 2019
f6e01e8
Add test for issue-48638
JohnTitor Oct 14, 2019
da1cddd
Rollup merge of #65215 - JohnTitor:long-explanation-e0697, r=Guillaum…
Centril Oct 14, 2019
28b6bb8
Rollup merge of #65265 - GuillaumeGomez:cleanup-librustc_mir-err-code…
Centril Oct 14, 2019
562e78e
Rollup merge of #65292 - JohnTitor:add-backticks, r=varkor,Centril
Centril Oct 14, 2019
85eb0a4
Rollup merge of #65362 - Centril:extract_fun, r=petrochenkov
Centril Oct 14, 2019
83679cb
Rollup merge of #65363 - Centril:less-pprust, r=Mark-Simulacrum
Centril Oct 14, 2019
d24da2a
Rollup merge of #65379 - Centril:refactor-bso_and_cc, r=petrochenkov
Centril Oct 14, 2019
c973cc2
Rollup merge of #65392 - Centril:nt-to-tt, r=Mark-Simulacrum
Centril Oct 14, 2019
045339c
Rollup merge of #65395 - JohnTitor:add-tests, r=Centril
Centril Oct 14, 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
19 changes: 18 additions & 1 deletion src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,24 @@ a (non-transparent) struct containing a single float, while `Grams` is a
transparent wrapper around a float. This can make a difference for the ABI.
"##,

E0697: r##"
A closure has been used as `static`.

Erroneous code example:

```compile_fail,E0697
fn main() {
static || {}; // used as `static`
}
```

Closures cannot be used as `static`. They "save" the environment,
and as such a static closure would save only a static environment
which would consist only of variables with a static lifetime. Given
this it would be better to use a proper function. The easiest fix
is to remove the `static` keyword.
"##,

E0698: r##"
When using generators (or async) all type variables must be bound so a
generator can be constructed.
Expand Down Expand Up @@ -2191,7 +2209,6 @@ See [RFC 2091] for details on this and other limitations.
E0657, // `impl Trait` can only capture lifetimes bound at the fn level
E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
E0697, // closures cannot be static
// E0707, // multiple elided lifetimes used in arguments of `async fn`
E0708, // `async` non-`move` closures with parameters are not currently
// supported
Expand Down
14 changes: 12 additions & 2 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ use syntax::print::pprust;
use syntax::source_map::{respan, ExpnData, ExpnKind, DesugaringKind, Spanned};
use syntax::symbol::{kw, sym, Symbol};
use syntax::tokenstream::{TokenStream, TokenTree};
use syntax::parse::token::{self, Token};
use syntax::parse::token::{self, Nonterminal, Token};
use syntax::parse::ParseSess;
use syntax::visit::{self, Visitor};
use syntax_pos::Span;

Expand All @@ -86,6 +87,11 @@ pub struct LoweringContext<'a> {

resolver: &'a mut dyn Resolver,

/// HACK(Centril): there is a cyclic dependency between the parser and lowering
/// if we don't have this function pointer. To avoid that dependency so that
/// librustc is independent of the parser, we use dynamic dispatch here.
nt_to_tokenstream: NtToTokenstream,

/// The items being lowered are collected here.
items: BTreeMap<hir::HirId, hir::Item>,

Expand Down Expand Up @@ -180,6 +186,8 @@ pub trait Resolver {
fn has_derives(&self, node_id: NodeId, derives: SpecialDerives) -> bool;
}

type NtToTokenstream = fn(&Nonterminal, &ParseSess, Span) -> TokenStream;

/// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree,
/// and if so, what meaning it has.
#[derive(Debug)]
Expand Down Expand Up @@ -236,6 +244,7 @@ pub fn lower_crate(
dep_graph: &DepGraph,
krate: &Crate,
resolver: &mut dyn Resolver,
nt_to_tokenstream: NtToTokenstream,
) -> hir::Crate {
// We're constructing the HIR here; we don't care what we will
// read, since we haven't even constructed the *input* to
Expand All @@ -249,6 +258,7 @@ pub fn lower_crate(
sess,
cstore,
resolver,
nt_to_tokenstream,
items: BTreeMap::new(),
trait_items: BTreeMap::new(),
impl_items: BTreeMap::new(),
Expand Down Expand Up @@ -1022,7 +1032,7 @@ impl<'a> LoweringContext<'a> {
fn lower_token(&mut self, token: Token) -> TokenStream {
match token.kind {
token::Interpolated(nt) => {
let tts = nt.to_tokenstream(&self.sess.parse_sess, token.span);
let tts = (self.nt_to_tokenstream)(&nt, &self.sess.parse_sess, token.span);
self.lower_token_stream(tts)
}
_ => TokenTree::Token(token).into(),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<'tcx> TyCtxt<'tcx> {
{
sp = param.span;
}
(format!("the lifetime {} as defined on", br.name), sp)
(format!("the lifetime `{}` as defined on", br.name), sp)
}
ty::ReFree(ty::FreeRegion {
bound_region: ty::BoundRegion::BrNamed(_, name),
Expand All @@ -213,15 +213,15 @@ impl<'tcx> TyCtxt<'tcx> {
{
sp = param.span;
}
(format!("the lifetime {} as defined on", name), sp)
(format!("the lifetime `{}` as defined on", name), sp)
}
ty::ReFree(ref fr) => match fr.bound_region {
ty::BrAnon(idx) => (
format!("the anonymous lifetime #{} defined on", idx + 1),
self.hir().span(node),
),
_ => (
format!("the lifetime {} as defined on", region),
format!("the lifetime `{}` as defined on", region),
cm.def_span(self.hir().span(node)),
),
},
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/lint/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHa
use syntax::ast;
use syntax::attr;
use syntax::feature_gate;
use syntax::print::pprust;
use syntax::source_map::MultiSpan;
use syntax::symbol::{Symbol, sym};

Expand Down Expand Up @@ -285,7 +286,7 @@ impl<'a> LintLevelsBuilder<'a> {
tool_ident.span,
E0710,
"an unknown tool name found in scoped lint: `{}`",
meta_item.path
pprust::path_to_string(&meta_item.path),
);
continue;
}
Expand Down
Loading