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 9 pull requests #100708

Merged
merged 32 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bdfc688
Add drop tracking version of must_not_suspend ref test
eholk Jun 9, 2022
89d3506
Update must_not_suspend lint to traverse references
eholk May 23, 2022
c42c77b
Update to still be correct without drop tracking
eholk Jun 10, 2022
0da8199
Fix after rebasing
eholk Jul 29, 2022
848f301
avoid assertion failures in try_to_scalar_int
RalfJung Jul 30, 2022
a73afe3
Improving Fuchsia rustc support documentation
andrewpollack Aug 16, 2022
1886aef
point at a type parameter shadowing another type
TaKO8Ki Aug 16, 2022
5a848c7
avoid a `&str` to `String` conversion
TaKO8Ki Aug 16, 2022
7e15fba
Added first migration for repeated expressions without syntax vars
nidnogg Aug 16, 2022
be18a9b
Migrated more diagnostics under transcribe.rs
nidnogg Aug 16, 2022
72ce216
Previous commit under x.py fmt
nidnogg Aug 16, 2022
2c24958
Remove `TraitDef::attributes`.
nnethercote Aug 17, 2022
6cd40d0
Remove `attrs` arg from `typaram` and `mk_ty_param`.
nnethercote Aug 17, 2022
52d8397
Remove `AttributesExt::other_attrs`.
nnethercote Aug 17, 2022
d3bf103
Fix documentation of rustc_parse::parser::Parser::parse_stmt_without_…
Xiretza Aug 17, 2022
98fb65e
Migrate lint reports in typeck::check_unused to LintDiagnostic
PragmaTwice Aug 17, 2022
52418d6
use `suggestion_short` in `LintDiagnostic`
PragmaTwice Aug 17, 2022
b704843
fix test file
PragmaTwice Aug 17, 2022
9efe979
remove #[primary_span]
PragmaTwice Aug 17, 2022
c6f9a9c
Moved structs to rustc_expand::errors, added several more migrations,…
nidnogg Aug 17, 2022
caab20c
Moved structs to rustc_expand::errors, added several more migrations,…
nidnogg Aug 17, 2022
a468f13
Hotfix for duplicated slug name on VarStillRepeating struct
nidnogg Aug 17, 2022
fc7fc0f
ty::Error does not match other types for region constraints
compiler-errors Aug 17, 2022
370bf15
Rollup merge of #97962 - eholk:drop-tracking-must-not-suspend, r=cjgi…
matthiaskrgr Aug 18, 2022
092f460
Rollup merge of #99966 - RalfJung:try-dont-panic, r=lcnr
matthiaskrgr Aug 18, 2022
795e55f
Rollup merge of #100637 - andrewpollack:fuchsia-docs-adjustments, r=t…
matthiaskrgr Aug 18, 2022
b295639
Rollup merge of #100643 - TaKO8Ki:point-at-type-parameter-shadowing-a…
matthiaskrgr Aug 18, 2022
8b180ed
Rollup merge of #100651 - nidnogg:diagnostics_migration_expand_transc…
matthiaskrgr Aug 18, 2022
3e057d1
Rollup merge of #100669 - nnethercote:attribute-cleanups, r=spastorino
matthiaskrgr Aug 18, 2022
5548e58
Rollup merge of #100670 - Xiretza:parser-stmt-force-collect-docs, r=d…
matthiaskrgr Aug 18, 2022
3de034d
Rollup merge of #100674 - PragmaTwice:mig-typeck-unused-crate-diag, r…
matthiaskrgr Aug 18, 2022
c7a4942
Rollup merge of #100688 - compiler-errors:issue-100684, r=wesleywiser
matthiaskrgr Aug 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub fn expand_deriving_copy(
) {
let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: path_std!(marker::Copy),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ pub fn expand_deriving_clone(
let attrs = vec![cx.attribute(inline)];
let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: path_std!(clone::Clone),
additional_bounds: bounds,
generics: Bounds::empty(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn expand_deriving_eq(
let attrs = vec![cx.attribute(inline), cx.attribute(doc), cx.attribute(no_coverage)];
let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: path_std!(cmp::Eq),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub fn expand_deriving_ord(
let attrs = vec![cx.attribute(inline)];
let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: path_std!(cmp::Ord),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ pub fn expand_deriving_partial_eq(

let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: path_std!(cmp::PartialEq),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub fn expand_deriving_partial_ord(

let trait_def = TraitDef {
span,
attributes: vec![],
path: path_std!(cmp::PartialOrd),
additional_bounds: vec![],
generics: Bounds::empty(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub fn expand_deriving_debug(

let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: path_std!(fmt::Debug),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub fn expand_deriving_rustc_decodable(

let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub fn expand_deriving_default(
let attrs = vec![cx.attribute(inline)];
let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: Path::new(vec![kw::Default, sym::Default]),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub fn expand_deriving_rustc_encodable(

let trait_def = TraitDef {
span,
attributes: Vec::new(),
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ pub struct TraitDef<'a> {
/// The span for the current #[derive(Foo)] header.
pub span: Span,

pub attributes: Vec<ast::Attribute>,

/// Path of the trait, including any type parameters
pub path: Path,

Expand Down Expand Up @@ -605,7 +603,7 @@ impl<'a> TraitDef<'a> {
param.bounds.iter().cloned()
).collect();

cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, vec![], bounds, None)
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
}
GenericParamKind::Const { ty, kw_span, .. } => {
let const_nodefault_kind = GenericParamKind::Const {
Expand Down Expand Up @@ -718,15 +716,13 @@ impl<'a> TraitDef<'a> {
let self_type = cx.ty_path(path);

let attr = cx.attribute(cx.meta_word(self.span, sym::automatically_derived));
let attrs = vec![attr];
let opt_trait_ref = Some(trait_ref);

let mut a = vec![attr];
a.extend(self.attributes.iter().cloned());

cx.item(
self.span,
Ident::empty(),
a,
attrs,
ast::ItemKind::Impl(Box::new(ast::Impl {
unsafety: ast::Unsafe::No,
polarity: ast::ImplPolarity::Positive,
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_builtin_macros/src/deriving/generic/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ fn mk_ty_param(
cx: &ExtCtxt<'_>,
span: Span,
name: Symbol,
attrs: &[ast::Attribute],
bounds: &[Path],
self_ident: Ident,
self_generics: &Generics,
Expand All @@ -158,7 +157,7 @@ fn mk_ty_param(
cx.trait_bound(path)
})
.collect();
cx.typaram(span, Ident::new(name, span), attrs.to_owned(), bounds, None)
cx.typaram(span, Ident::new(name, span), bounds, None)
}

/// Bounds on type parameters.
Expand All @@ -183,7 +182,7 @@ impl Bounds {
.iter()
.map(|t| {
let (name, ref bounds) = *t;
mk_ty_param(cx, span, name, &[], &bounds, self_ty, self_generics)
mk_ty_param(cx, span, name, &bounds, self_ty, self_generics)
})
.collect();

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_builtin_macros/src/deriving/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub fn expand_deriving_hash(
let arg = Path::new_local(typaram);
let hash_trait_def = TraitDef {
span,
attributes: Vec::new(),
path,
additional_bounds: Vec::new(),
generics: Bounds::empty(),
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/expand.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@ expand_explain_doc_comment_outer =

expand_explain_doc_comment_inner =
inner doc comments expand to `#![doc = "..."]`, which is what this macro attempted to match

expand_expr_repeat_no_syntax_vars =
attempted to repeat an expression containing no syntax variables matched as repeating at this depth

expand_must_repeat_once =
this must repeat at least once

expand_count_repetition_misplaced =
`count` can not be placed inside the inner-most repetition

expand_meta_var_expr_unrecognized_var =
variable `{$key}` is not recognized in meta-variable expression

expand_var_still_repeating =
variable '{$ident}' is still repeating at this depth

expand_meta_var_dif_seq_matchers = {$msg}
8 changes: 8 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/typeck.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,11 @@ typeck_manual_implementation =
.help = add `#![feature(unboxed_closures)]` to the crate attributes to enable

typeck_substs_on_overridden_impl = could not resolve substs on overridden impl

typeck_unused_extern_crate =
unused extern crate
.suggestion = remove it

typeck_extern_crate_not_idiomatic =
`extern crate` is not idiomatic in the new edition
.suggestion = convert it to a `{$msg_code}`
3 changes: 2 additions & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_error_messages::FluentValue;
use rustc_hir as hir;
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_span::edition::LATEST_STABLE_EDITION;
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
use rustc_span::{edition::Edition, Span, DUMMY_SP};
use std::borrow::Cow;
use std::fmt;
Expand Down Expand Up @@ -87,6 +87,7 @@ into_diagnostic_arg_using_display!(
hir::Target,
Edition,
Ident,
MacroRulesNormalizedIdent,
);

impl IntoDiagnosticArg for bool {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_expand/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,13 @@ impl<'a> ExtCtxt<'a> {
&self,
span: Span,
ident: Ident,
attrs: Vec<ast::Attribute>,
bounds: ast::GenericBounds,
default: Option<P<ast::Ty>>,
) -> ast::GenericParam {
ast::GenericParam {
ident: ident.with_span_pos(span),
id: ast::DUMMY_NODE_ID,
attrs: attrs.into(),
attrs: AttrVec::new(),
bounds,
kind: ast::GenericParamKind::Type { default },
is_placeholder: false,
Expand Down
48 changes: 48 additions & 0 deletions compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use rustc_macros::SessionDiagnostic;
use rustc_span::symbol::MacroRulesNormalizedIdent;
use rustc_span::Span;

#[derive(SessionDiagnostic)]
#[error(expand::expr_repeat_no_syntax_vars)]
pub(crate) struct NoSyntaxVarsExprRepeat {
#[primary_span]
pub span: Span,
}

#[derive(SessionDiagnostic)]
#[error(expand::must_repeat_once)]
pub(crate) struct MustRepeatOnce {
#[primary_span]
pub span: Span,
}

#[derive(SessionDiagnostic)]
#[error(expand::count_repetition_misplaced)]
pub(crate) struct CountRepetitionMisplaced {
#[primary_span]
pub span: Span,
}

#[derive(SessionDiagnostic)]
#[error(expand::meta_var_expr_unrecognized_var)]
pub(crate) struct MetaVarExprUnrecognizedVar {
#[primary_span]
pub span: Span,
pub key: MacroRulesNormalizedIdent,
}

#[derive(SessionDiagnostic)]
#[error(expand::var_still_repeating)]
pub(crate) struct VarStillRepeating {
#[primary_span]
pub span: Span,
pub ident: MacroRulesNormalizedIdent,
}

#[derive(SessionDiagnostic)]
#[error(expand::meta_var_dif_seq_matchers)]
pub(crate) struct MetaVarsDifSeqMatchers {
#[primary_span]
pub span: Span,
pub msg: String,
}
1 change: 1 addition & 0 deletions compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod base;
pub mod build;
#[macro_use]
pub mod config;
pub mod errors;
pub mod expand;
pub mod module;
pub mod proc_macro;
Expand Down
34 changes: 10 additions & 24 deletions compiler/rustc_expand/src/mbe/transcribe.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use crate::base::ExtCtxt;
use crate::errors::{
CountRepetitionMisplaced, MetaVarExprUnrecognizedVar, MetaVarsDifSeqMatchers, MustRepeatOnce,
NoSyntaxVarsExprRepeat, VarStillRepeating,
};
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, MatchedTokenTree, NamedMatch};
use crate::mbe::{self, MetaVarExpr};
use rustc_ast::mut_visit::{self, MutVisitor};
Expand Down Expand Up @@ -165,19 +169,15 @@ pub(super) fn transcribe<'a>(
seq @ mbe::TokenTree::Sequence(_, delimited) => {
match lockstep_iter_size(&seq, interp, &repeats) {
LockstepIterSize::Unconstrained => {
return Err(cx.struct_span_err(
seq.span(), /* blame macro writer */
"attempted to repeat an expression containing no syntax variables \
matched as repeating at this depth",
));
return Err(cx.create_err(NoSyntaxVarsExprRepeat { span: seq.span() }));
}

LockstepIterSize::Contradiction(msg) => {
// FIXME: this really ought to be caught at macro definition time... It
// happens when two meta-variables are used in the same repetition in a
// sequence, but they come from different sequence matchers and repeat
// different amounts.
return Err(cx.struct_span_err(seq.span(), &msg));
return Err(cx.create_err(MetaVarsDifSeqMatchers { span: seq.span(), msg }));
}

LockstepIterSize::Constraint(len, _) => {
Expand All @@ -193,10 +193,7 @@ pub(super) fn transcribe<'a>(
// FIXME: this really ought to be caught at macro definition
// time... It happens when the Kleene operator in the matcher and
// the body for the same meta-variable do not match.
return Err(cx.struct_span_err(
sp.entire(),
"this must repeat at least once",
));
return Err(cx.create_err(MustRepeatOnce { span: sp.entire() }));
}
} else {
// 0 is the initial counter (we have done 0 repetitions so far). `len`
Expand Down Expand Up @@ -239,10 +236,7 @@ pub(super) fn transcribe<'a>(
}
MatchedSeq(..) => {
// We were unable to descend far enough. This is an error.
return Err(cx.struct_span_err(
sp, /* blame the macro writer */
&format!("variable '{}' is still repeating at this depth", ident),
));
return Err(cx.create_err(VarStillRepeating { span: sp, ident }));
}
}
} else {
Expand Down Expand Up @@ -448,10 +442,7 @@ fn count_repetitions<'a>(
match matched {
MatchedTokenTree(_) | MatchedNonterminal(_) => {
if declared_lhs_depth == 0 {
return Err(cx.struct_span_err(
sp.entire(),
"`count` can not be placed inside the inner-most repetition",
));
return Err(cx.create_err(CountRepetitionMisplaced { span: sp.entire() }));
}
match depth_opt {
None => Ok(1),
Expand Down Expand Up @@ -499,12 +490,7 @@ where
{
let span = ident.span;
let key = MacroRulesNormalizedIdent::new(ident);
interp.get(&key).ok_or_else(|| {
cx.struct_span_err(
span,
&format!("variable `{}` is not recognized in meta-variable expression", key),
)
})
interp.get(&key).ok_or_else(|| cx.create_err(MetaVarExprUnrecognizedVar { span, key }))
}

/// Used by meta-variable expressions when an user input is out of the actual declared bounds. For
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_infer/src/infer/outlives/test_type_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,14 @@ impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {

#[instrument(skip(self), level = "debug")]
fn tys(&mut self, pattern: Ty<'tcx>, value: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
if pattern == value { Ok(pattern) } else { relate::super_relate_tys(self, pattern, value) }
if let ty::Error(_) = pattern.kind() {
// Unlike normal `TypeRelation` rules, `ty::Error` does not equal any type.
self.no_match()
} else if pattern == value {
Ok(pattern)
} else {
relate::super_relate_tys(self, pattern, value)
}
}

#[instrument(skip(self), level = "debug")]
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_middle/src/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'tcx> ConstValue<'tcx> {
}

pub fn try_to_scalar_int(&self) -> Option<ScalarInt> {
Some(self.try_to_scalar()?.assert_int())
self.try_to_scalar()?.try_to_int().ok()
}

pub fn try_to_bits(&self, size: Size) -> Option<u128> {
Expand Down Expand Up @@ -368,6 +368,7 @@ impl<'tcx, Prov: Provenance> Scalar<Prov> {
}

#[inline(always)]
#[cfg_attr(debug_assertions, track_caller)] // only in debug builds due to perf (see #98980)
pub fn assert_int(self) -> ScalarInt {
self.try_to_int().unwrap()
}
Expand All @@ -389,6 +390,7 @@ impl<'tcx, Prov: Provenance> Scalar<Prov> {
}

#[inline(always)]
#[cfg_attr(debug_assertions, track_caller)] // only in debug builds due to perf (see #98980)
pub fn assert_bits(self, target_size: Size) -> u128 {
self.to_bits(target_size).unwrap()
}
Expand Down
Loading