Skip to content

Commit 04a41f8

Browse files
committedJan 20, 2023
Auto merge of #107105 - matthiaskrgr:rollup-rkz9t7r, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #106783 (Recover labels written as identifiers) - #106973 (Don't treat closures from other crates as local) - #106979 (Document how to get the type of a default associated type) - #107053 (signal update string representation for haiku.) - #107058 (Recognise double-equals homoglyph) - #107067 (Custom MIR: Support storage statements) - #107076 (Added const-generic ui test case for issue #106419) - #107091 (Fix broken format strings in `infer.ftl`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 56ee852 + c42fad8 commit 04a41f8

File tree

20 files changed

+532
-365
lines changed

20 files changed

+532
-365
lines changed
 

‎compiler/rustc_error_messages/locales/en-US/infer.ftl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ infer_actual_impl_expl_expected_signature_any = {$leading_ellipsis ->
193193
infer_actual_impl_expl_expected_signature_some = {$leading_ellipsis ->
194194
[true] ...
195195
*[false] {""}
196-
}closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{lifetime_1}`...
196+
}closure with signature `{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{$lifetime_1}`...
197197
infer_actual_impl_expl_expected_signature_nothing = {$leading_ellipsis ->
198198
[true] ...
199199
*[false] {""}
@@ -209,7 +209,7 @@ infer_actual_impl_expl_expected_passive_any = {$leading_ellipsis ->
209209
infer_actual_impl_expl_expected_passive_some = {$leading_ellipsis ->
210210
[true] ...
211211
*[false] {""}
212-
}`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for some specific lifetime `'{lifetime_1}`...
212+
}`{$trait_path}` would have to be implemented for the type `{$ty_or_sig}`, for some specific lifetime `'{$lifetime_1}`...
213213
infer_actual_impl_expl_expected_passive_nothing = {$leading_ellipsis ->
214214
[true] ...
215215
*[false] {""}
@@ -225,7 +225,7 @@ infer_actual_impl_expl_expected_other_any = {$leading_ellipsis ->
225225
infer_actual_impl_expl_expected_other_some = {$leading_ellipsis ->
226226
[true] ...
227227
*[false] {""}
228-
}`{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{lifetime_1}`...
228+
}`{$ty_or_sig}` must implement `{$trait_path}`, for some specific lifetime `'{$lifetime_1}`...
229229
infer_actual_impl_expl_expected_other_nothing = {$leading_ellipsis ->
230230
[true] ...
231231
*[false] {""}
@@ -268,11 +268,11 @@ infer_but_calling_introduces = {$has_param_name ->
268268
[true] `{$param_name}`
269269
*[false] `fn` parameter
270270
} has {$lifetime_kind ->
271-
[named] lifetime `{lifetime}`
271+
[named] lifetime `{$lifetime}`
272272
*[anon] an anonymous lifetime `'_`
273273
} but calling `{assoc_item}` introduces an implicit `'static` lifetime requirement
274274
.label1 = {$has_lifetime ->
275-
[named] lifetime `{lifetime}`
275+
[named] lifetime `{$lifetime}`
276276
*[anon] an anonymous lifetime `'_`
277277
}
278278
.label2 = ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the {$has_impl_path ->
@@ -284,11 +284,11 @@ infer_but_needs_to_satisfy = {$has_param_name ->
284284
[true] `{$param_name}`
285285
*[false] `fn` parameter
286286
} has {$has_lifetime ->
287-
[named] lifetime `{lifetime}`
287+
[named] lifetime `{$lifetime}`
288288
*[anon] an anonymous lifetime `'_`
289289
} but it needs to satisfy a `'static` lifetime requirement
290290
.influencer = this data with {$has_lifetime ->
291-
[named] lifetime `{lifetime}`
291+
[named] lifetime `{$lifetime}`
292292
*[anon] an anonymous lifetime `'_`
293293
}...
294294
.require = {$spans_empty ->
@@ -302,7 +302,7 @@ infer_more_targeted = {$has_param_name ->
302302
[true] `{$param_name}`
303303
*[false] `fn` parameter
304304
} has {$has_lifetime ->
305-
[named] lifetime `{lifetime}`
305+
[named] lifetime `{$lifetime}`
306306
*[anon] an anonymous lifetime `'_`
307307
} but calling `{$ident}` introduces an implicit `'static` lifetime requirement
308308

‎compiler/rustc_middle/src/ty/assoc.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ impl AssocItem {
3737
Ident::new(self.name, tcx.def_ident_span(self.def_id).unwrap())
3838
}
3939

40+
/// Gets the defaultness of the associated item.
41+
/// To get the default associated type, use the [`type_of`] query on the
42+
/// [`DefId`] of the type.
43+
///
44+
/// [`type_of`]: crate::ty::TyCtxt::type_of
4045
pub fn defaultness(&self, tcx: TyCtxt<'_>) -> hir::Defaultness {
4146
tcx.impl_defaultness(self.def_id)
4247
}

‎compiler/rustc_mir_build/src/build/custom/parse/instruction.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ use super::{parse_by_kind, PResult, ParseCtxt};
1212
impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
1313
pub fn parse_statement(&self, expr_id: ExprId) -> PResult<StatementKind<'tcx>> {
1414
parse_by_kind!(self, expr_id, _, "statement",
15+
@call("mir_storage_live", args) => {
16+
Ok(StatementKind::StorageLive(self.parse_local(args[0])?))
17+
},
18+
@call("mir_storage_dead", args) => {
19+
Ok(StatementKind::StorageDead(self.parse_local(args[0])?))
20+
},
1521
@call("mir_retag", args) => {
1622
Ok(StatementKind::Retag(RetagKind::Default, Box::new(self.parse_place(args[0])?)))
1723
},

‎compiler/rustc_parse/src/lexer/unicode_chars.rs

Lines changed: 322 additions & 320 deletions
Large diffs are not rendered by default.

‎compiler/rustc_parse/src/parser/expr.rs

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,9 +1353,6 @@ impl<'a> Parser<'a> {
13531353
err.span_label(sp, "while parsing this `loop` expression");
13541354
err
13551355
})
1356-
} else if self.eat_keyword(kw::Continue) {
1357-
let kind = ExprKind::Continue(self.eat_label());
1358-
Ok(self.mk_expr(lo.to(self.prev_token.span), kind))
13591356
} else if self.eat_keyword(kw::Match) {
13601357
let match_sp = self.prev_token.span;
13611358
self.parse_match_expr().map_err(|mut err| {
@@ -1379,6 +1376,8 @@ impl<'a> Parser<'a> {
13791376
self.parse_try_block(lo)
13801377
} else if self.eat_keyword(kw::Return) {
13811378
self.parse_return_expr()
1379+
} else if self.eat_keyword(kw::Continue) {
1380+
self.parse_continue_expr(lo)
13821381
} else if self.eat_keyword(kw::Break) {
13831382
self.parse_break_expr()
13841383
} else if self.eat_keyword(kw::Yield) {
@@ -1715,10 +1714,10 @@ impl<'a> Parser<'a> {
17151714
fn parse_break_expr(&mut self) -> PResult<'a, P<Expr>> {
17161715
let lo = self.prev_token.span;
17171716
let mut label = self.eat_label();
1718-
let kind = if label.is_some() && self.token == token::Colon {
1717+
let kind = if self.token == token::Colon && let Some(label) = label.take() {
17191718
// The value expression can be a labeled loop, see issue #86948, e.g.:
17201719
// `loop { break 'label: loop { break 'label 42; }; }`
1721-
let lexpr = self.parse_labeled_expr(label.take().unwrap(), true)?;
1720+
let lexpr = self.parse_labeled_expr(label, true)?;
17221721
self.sess.emit_err(LabeledLoopInBreak {
17231722
span: lexpr.span,
17241723
sub: WrapExpressionInParentheses {
@@ -1730,8 +1729,8 @@ impl<'a> Parser<'a> {
17301729
} else if self.token != token::OpenDelim(Delimiter::Brace)
17311730
|| !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL)
17321731
{
1733-
let expr = self.parse_expr_opt()?;
1734-
if let Some(expr) = &expr {
1732+
let mut expr = self.parse_expr_opt()?;
1733+
if let Some(expr) = &mut expr {
17351734
if label.is_some()
17361735
&& matches!(
17371736
expr.kind,
@@ -1749,7 +1748,19 @@ impl<'a> Parser<'a> {
17491748
BuiltinLintDiagnostics::BreakWithLabelAndLoop(expr.span),
17501749
);
17511750
}
1751+
1752+
// Recover `break label aaaaa`
1753+
if self.may_recover()
1754+
&& let ExprKind::Path(None, p) = &expr.kind
1755+
&& let [segment] = &*p.segments
1756+
&& let &ast::PathSegment { ident, args: None, .. } = segment
1757+
&& let Some(next) = self.parse_expr_opt()?
1758+
{
1759+
label = Some(self.recover_ident_into_label(ident));
1760+
*expr = next;
1761+
}
17521762
}
1763+
17531764
expr
17541765
} else {
17551766
None
@@ -1758,6 +1769,23 @@ impl<'a> Parser<'a> {
17581769
self.maybe_recover_from_bad_qpath(expr)
17591770
}
17601771

1772+
/// Parse `"continue" label?`.
1773+
fn parse_continue_expr(&mut self, lo: Span) -> PResult<'a, P<Expr>> {
1774+
let mut label = self.eat_label();
1775+
1776+
// Recover `continue label` -> `continue 'label`
1777+
if self.may_recover()
1778+
&& label.is_none()
1779+
&& let Some((ident, _)) = self.token.ident()
1780+
{
1781+
self.bump();
1782+
label = Some(self.recover_ident_into_label(ident));
1783+
}
1784+
1785+
let kind = ExprKind::Continue(label);
1786+
Ok(self.mk_expr(lo.to(self.prev_token.span), kind))
1787+
}
1788+
17611789
/// Parse `"yield" expr?`.
17621790
fn parse_yield_expr(&mut self) -> PResult<'a, P<Expr>> {
17631791
let lo = self.prev_token.span;
@@ -3046,6 +3074,25 @@ impl<'a> Parser<'a> {
30463074
false
30473075
}
30483076

3077+
/// Converts an ident into 'label and emits an "expected a label, found an identifier" error.
3078+
fn recover_ident_into_label(&mut self, ident: Ident) -> Label {
3079+
// Convert `label` -> `'label`,
3080+
// so that nameres doesn't complain about non-existing label
3081+
let label = format!("'{}", ident.name);
3082+
let ident = Ident { name: Symbol::intern(&label), span: ident.span };
3083+
3084+
self.struct_span_err(ident.span, "expected a label, found an identifier")
3085+
.span_suggestion(
3086+
ident.span,
3087+
"labels start with a tick",
3088+
label,
3089+
Applicability::MachineApplicable,
3090+
)
3091+
.emit();
3092+
3093+
Label { ident }
3094+
}
3095+
30493096
/// Parses `ident (COLON expr)?`.
30503097
fn parse_expr_field(&mut self) -> PResult<'a, ExprField> {
30513098
let attrs = self.parse_outer_attributes()?;

‎compiler/rustc_trait_selection/src/traits/coherence.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,12 @@ fn resolve_negative_obligation<'tcx>(
401401
infcx.resolve_regions(&outlives_env).is_empty()
402402
}
403403

404+
#[instrument(level = "debug", skip(tcx), ret)]
404405
pub fn trait_ref_is_knowable<'tcx>(
405406
tcx: TyCtxt<'tcx>,
406407
trait_ref: ty::TraitRef<'tcx>,
407408
) -> Result<(), Conflict> {
408-
debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref);
409-
if orphan_check_trait_ref(tcx, trait_ref, InCrate::Remote).is_ok() {
409+
if orphan_check_trait_ref(trait_ref, InCrate::Remote).is_ok() {
410410
// A downstream or cousin crate is allowed to implement some
411411
// substitution of this trait-ref.
412412
return Err(Conflict::Downstream);
@@ -429,11 +429,9 @@ pub fn trait_ref_is_knowable<'tcx>(
429429
// and if we are an intermediate owner, then we don't care
430430
// about future-compatibility, which means that we're OK if
431431
// we are an owner.
432-
if orphan_check_trait_ref(tcx, trait_ref, InCrate::Local).is_ok() {
433-
debug!("trait_ref_is_knowable: orphan check passed");
432+
if orphan_check_trait_ref(trait_ref, InCrate::Local).is_ok() {
434433
Ok(())
435434
} else {
436-
debug!("trait_ref_is_knowable: nonlocal, nonfundamental, unowned");
437435
Err(Conflict::Upstream)
438436
}
439437
}
@@ -445,6 +443,7 @@ pub fn trait_ref_is_local_or_fundamental<'tcx>(
445443
trait_ref.def_id.krate == LOCAL_CRATE || tcx.has_attr(trait_ref.def_id, sym::fundamental)
446444
}
447445

446+
#[derive(Debug)]
448447
pub enum OrphanCheckErr<'tcx> {
449448
NonLocalInputType(Vec<(Ty<'tcx>, bool /* Is this the first input type? */)>),
450449
UncoveredTy(Ty<'tcx>, Option<Ty<'tcx>>),
@@ -456,21 +455,20 @@ pub enum OrphanCheckErr<'tcx> {
456455
///
457456
/// 1. All type parameters in `Self` must be "covered" by some local type constructor.
458457
/// 2. Some local type must appear in `Self`.
458+
#[instrument(level = "debug", skip(tcx), ret)]
459459
pub fn orphan_check(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Result<(), OrphanCheckErr<'_>> {
460-
debug!("orphan_check({:?})", impl_def_id);
461-
462460
// We only except this routine to be invoked on implementations
463461
// of a trait, not inherent implementations.
464462
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap().subst_identity();
465-
debug!("orphan_check: trait_ref={:?}", trait_ref);
463+
debug!(?trait_ref);
466464

467465
// If the *trait* is local to the crate, ok.
468466
if trait_ref.def_id.is_local() {
469467
debug!("trait {:?} is local to current crate", trait_ref.def_id);
470468
return Ok(());
471469
}
472470

473-
orphan_check_trait_ref(tcx, trait_ref, InCrate::Local)
471+
orphan_check_trait_ref(trait_ref, InCrate::Local)
474472
}
475473

476474
/// Checks whether a trait-ref is potentially implementable by a crate.
@@ -559,21 +557,19 @@ pub fn orphan_check(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Result<(), OrphanChe
559557
///
560558
/// Note that this function is never called for types that have both type
561559
/// parameters and inference variables.
560+
#[instrument(level = "trace", ret)]
562561
fn orphan_check_trait_ref<'tcx>(
563-
tcx: TyCtxt<'tcx>,
564562
trait_ref: ty::TraitRef<'tcx>,
565563
in_crate: InCrate,
566564
) -> Result<(), OrphanCheckErr<'tcx>> {
567-
debug!("orphan_check_trait_ref(trait_ref={:?}, in_crate={:?})", trait_ref, in_crate);
568-
569565
if trait_ref.needs_infer() && trait_ref.needs_subst() {
570566
bug!(
571567
"can't orphan check a trait ref with both params and inference variables {:?}",
572568
trait_ref
573569
);
574570
}
575571

576-
let mut checker = OrphanChecker::new(tcx, in_crate);
572+
let mut checker = OrphanChecker::new(in_crate);
577573
match trait_ref.visit_with(&mut checker) {
578574
ControlFlow::Continue(()) => Err(OrphanCheckErr::NonLocalInputType(checker.non_local_tys)),
579575
ControlFlow::Break(OrphanCheckEarlyExit::ParamTy(ty)) => {
@@ -592,7 +588,6 @@ fn orphan_check_trait_ref<'tcx>(
592588
}
593589

594590
struct OrphanChecker<'tcx> {
595-
tcx: TyCtxt<'tcx>,
596591
in_crate: InCrate,
597592
in_self_ty: bool,
598593
/// Ignore orphan check failures and exclusively search for the first
@@ -602,9 +597,8 @@ struct OrphanChecker<'tcx> {
602597
}
603598

604599
impl<'tcx> OrphanChecker<'tcx> {
605-
fn new(tcx: TyCtxt<'tcx>, in_crate: InCrate) -> Self {
600+
fn new(in_crate: InCrate) -> Self {
606601
OrphanChecker {
607-
tcx,
608602
in_crate,
609603
in_self_ty: true,
610604
search_first_local_ty: false,
@@ -697,13 +691,17 @@ impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> {
697691
}
698692
}
699693
ty::Error(_) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
700-
ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) => {
701-
self.tcx.sess.delay_span_bug(
702-
DUMMY_SP,
703-
format!("ty_is_local invoked on closure or generator: {:?}", ty),
704-
);
705-
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
694+
ty::Closure(did, ..) | ty::Generator(did, ..) => {
695+
if self.def_id_is_local(did) {
696+
ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty))
697+
} else {
698+
self.found_non_local_ty(ty)
699+
}
706700
}
701+
// This should only be created when checking whether we have to check whether some
702+
// auto trait impl applies. There will never be multiple impls, so we can just
703+
// act as if it were a local type here.
704+
ty::GeneratorWitness(_) => ControlFlow::Break(OrphanCheckEarlyExit::LocalTy(ty)),
707705
ty::Alias(ty::Opaque, ..) => {
708706
// This merits some explanation.
709707
// Normally, opaque types are not involved when performing

‎library/core/src/intrinsics/mir.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ define!("mir_unreachable", fn Unreachable() -> BasicBlock);
259259
define!("mir_drop", fn Drop<T>(place: T, goto: BasicBlock));
260260
define!("mir_drop_and_replace", fn DropAndReplace<T>(place: T, value: T, goto: BasicBlock));
261261
define!("mir_call", fn Call<T>(place: T, goto: BasicBlock, call: T));
262+
define!("mir_storage_live", fn StorageLive<T>(local: T));
263+
define!("mir_storage_dead", fn StorageDead<T>(local: T));
262264
define!("mir_retag", fn Retag<T>(place: T));
263265
define!("mir_move", fn Move<T>(place: T) -> T);
264266
define!("mir_static", fn Static<T>(s: T) -> &'static T);

‎library/std/src/sys/unix/process/process_unix.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,8 @@ fn signal_string(signal: i32) -> &'static str {
746746
libc::SIGWINCH => " (SIGWINCH)",
747747
#[cfg(not(target_os = "haiku"))]
748748
libc::SIGIO => " (SIGIO)",
749+
#[cfg(target_os = "haiku")]
750+
libc::SIGPOLL => " (SIGPOLL)",
749751
libc::SIGSYS => " (SIGSYS)",
750752
// For information on Linux signals, run `man 7 signal`
751753
#[cfg(all(

‎tests/mir-opt/building/custom/simple_assign.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ pub fn simple(x: i32) -> i32 {
1111
let temp2: _;
1212

1313
{
14+
StorageLive(temp1);
1415
temp1 = x;
1516
Goto(exit)
1617
}
1718

1819
exit = {
1920
temp2 = Move(temp1);
21+
StorageDead(temp1);
2022
RET = temp2;
2123
Return()
2224
}

‎tests/mir-opt/building/custom/simple_assign.simple.built.after.mir

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ fn simple(_1: i32) -> i32 {
66
let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
77

88
bb0: {
9-
_2 = _1; // scope 0 at $DIR/simple_assign.rs:+6:13: +6:22
10-
goto -> bb1; // scope 0 at $DIR/simple_assign.rs:+7:13: +7:23
9+
StorageLive(_2); // scope 0 at $DIR/simple_assign.rs:+6:13: +6:31
10+
_2 = _1; // scope 0 at $DIR/simple_assign.rs:+7:13: +7:22
11+
goto -> bb1; // scope 0 at $DIR/simple_assign.rs:+8:13: +8:23
1112
}
1213

1314
bb1: {
14-
_3 = move _2; // scope 0 at $DIR/simple_assign.rs:+11:13: +11:32
15-
_0 = _3; // scope 0 at $DIR/simple_assign.rs:+12:13: +12:24
16-
return; // scope 0 at $DIR/simple_assign.rs:+13:13: +13:21
15+
_3 = move _2; // scope 0 at $DIR/simple_assign.rs:+12:13: +12:32
16+
StorageDead(_2); // scope 0 at $DIR/simple_assign.rs:+13:13: +13:31
17+
_0 = _3; // scope 0 at $DIR/simple_assign.rs:+14:13: +14:24
18+
return; // scope 0 at $DIR/simple_assign.rs:+15:13: +15:21
1719
}
1820
}

‎tests/ui/coherence/coherence-with-generator.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Test that encountering closures during coherence does not cause issues.
22
#![feature(type_alias_impl_trait, generators)]
3+
#![cfg_attr(specialized, feature(specialization))]
4+
#![allow(incomplete_features)]
5+
6+
// revisions: stock specialized
7+
// [specialized]check-pass
8+
39
type OpaqueGenerator = impl Sized;
410
fn defining_use() -> OpaqueGenerator {
511
|| {
@@ -13,6 +19,6 @@ struct Wrapper<T>(T);
1319
trait Trait {}
1420
impl Trait for Wrapper<OpaqueGenerator> {}
1521
impl<T: Sync> Trait for Wrapper<T> {}
16-
//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>`
22+
//[stock]~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>`
1723

1824
fn main() {}

‎tests/ui/coherence/coherence-with-generator.stderr renamed to ‎tests/ui/coherence/coherence-with-generator.stock.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>`
2-
--> $DIR/coherence-with-generator.rs:15:1
2+
--> $DIR/coherence-with-generator.rs:21:1
33
|
44
LL | impl Trait for Wrapper<OpaqueGenerator> {}
55
| --------------------------------------- first implementation here
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
#![feature(generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
5+
#[derive(Clone)]
6+
struct Bar<const A: usize, const B: usize>
7+
where
8+
[(); A as usize]:,
9+
[(); B as usize]:,
10+
{}
11+
12+
fn main() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// run-rustfix
2+
3+
fn main() {
4+
'label: loop { break 'label }; //~ error: cannot find value `label` in this scope
5+
'label: loop { break 'label 0 }; //~ error: expected a label, found an identifier
6+
'label: loop { continue 'label }; //~ error: expected a label, found an identifier
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// run-rustfix
2+
3+
fn main() {
4+
'label: loop { break label }; //~ error: cannot find value `label` in this scope
5+
'label: loop { break label 0 }; //~ error: expected a label, found an identifier
6+
'label: loop { continue label }; //~ error: expected a label, found an identifier
7+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: expected a label, found an identifier
2+
--> $DIR/recover-unticked-labels.rs:5:26
3+
|
4+
LL | 'label: loop { break label 0 };
5+
| ^^^^^ help: labels start with a tick: `'label`
6+
7+
error: expected a label, found an identifier
8+
--> $DIR/recover-unticked-labels.rs:6:29
9+
|
10+
LL | 'label: loop { continue label };
11+
| ^^^^^ help: labels start with a tick: `'label`
12+
13+
error[E0425]: cannot find value `label` in this scope
14+
--> $DIR/recover-unticked-labels.rs:4:26
15+
|
16+
LL | 'label: loop { break label };
17+
| ------ ^^^^^
18+
| | |
19+
| | not found in this scope
20+
| | help: use the similarly named label: `'label`
21+
| a label with a similar name exists
22+
23+
error: aborting due to 3 previous errors
24+
25+
For more information about this error, try `rustc --explain E0425`.

‎tests/ui/parser/unicode-chars.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ fn main() {
66
//~^ ERROR unknown start of token: \u{a0}
77
//~^^ NOTE character appears 3 more times
88
//~^^^ HELP Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not
9+
let _ = 12;
10+
//~^ ERROR unknown start of token
11+
//~^^ HELP Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not
912
}

‎tests/ui/parser/unicode-chars.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,16 @@ help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is
2121
LL | let x = 0;
2222
| ++++
2323

24-
error: aborting due to 2 previous errors
24+
error: unknown start of token: \u{2a75}
25+
--> $DIR/unicode-chars.rs:9:15
26+
|
27+
LL | let _ = 1 ⩵ 2;
28+
| ^
29+
|
30+
help: Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not
31+
|
32+
LL | let _ = 1 == 2;
33+
| ~~
34+
35+
error: aborting due to 3 previous errors
2536

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(type_alias_impl_trait)]
2+
#![cfg_attr(specialized, feature(specialization))]
3+
#![allow(incomplete_features)]
4+
5+
// revisions: stock specialized
6+
// [specialized]check-pass
7+
8+
trait OpaqueTrait {}
9+
impl<T> OpaqueTrait for T {}
10+
type OpaqueType = impl OpaqueTrait;
11+
fn mk_opaque() -> OpaqueType {
12+
|| 0
13+
}
14+
trait AnotherTrait {}
15+
impl<T: Send> AnotherTrait for T {}
16+
impl AnotherTrait for OpaqueType {}
17+
//[stock]~^ conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
18+
19+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
2+
--> $DIR/issue-104817.rs:16:1
3+
|
4+
LL | impl<T: Send> AnotherTrait for T {}
5+
| -------------------------------- first implementation here
6+
LL | impl AnotherTrait for OpaqueType {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType`
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0119`.

0 commit comments

Comments
 (0)
Please sign in to comment.