mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 10:33:34 +00:00
Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakis
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021 This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition. r? `@estebank`
This commit is contained in:
commit
7a0f1781d0
@ -46,7 +46,7 @@ use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Namespace, PartialRes, PerNS, Res};
|
||||
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, CRATE_DEF_ID};
|
||||
@ -58,6 +58,7 @@ use rustc_session::lint::builtin::{BARE_TRAIT_OBJECTS, MISSING_ABI};
|
||||
use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer};
|
||||
use rustc_session::utils::{FlattenNonterminals, NtToTokenstream};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::ExpnId;
|
||||
use rustc_span::source_map::{respan, DesugaringKind};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
@ -2730,13 +2731,26 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
.map(|snippet| snippet.starts_with("#["))
|
||||
.unwrap_or(true);
|
||||
if !is_macro_callsite {
|
||||
self.resolver.lint_buffer().buffer_lint_with_diagnostic(
|
||||
BARE_TRAIT_OBJECTS,
|
||||
id,
|
||||
span,
|
||||
"trait objects without an explicit `dyn` are deprecated",
|
||||
BuiltinLintDiagnostics::BareTraitObject(span, is_global),
|
||||
)
|
||||
if span.edition() < Edition::Edition2021 {
|
||||
self.resolver.lint_buffer().buffer_lint_with_diagnostic(
|
||||
BARE_TRAIT_OBJECTS,
|
||||
id,
|
||||
span,
|
||||
"trait objects without an explicit `dyn` are deprecated",
|
||||
BuiltinLintDiagnostics::BareTraitObject(span, is_global),
|
||||
)
|
||||
} else {
|
||||
let msg = "trait objects must include the `dyn` keyword";
|
||||
let label = "add `dyn` keyword before this trait";
|
||||
let mut err = struct_span_err!(self.sess, span, E0782, "{}", msg,);
|
||||
err.span_suggestion_verbose(
|
||||
span.shrink_to_lo(),
|
||||
label,
|
||||
String::from("dyn "),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,6 +470,8 @@ E0778: include_str!("./error_codes/E0778.md"),
|
||||
E0779: include_str!("./error_codes/E0779.md"),
|
||||
E0780: include_str!("./error_codes/E0780.md"),
|
||||
E0781: include_str!("./error_codes/E0781.md"),
|
||||
E0782: include_str!("./error_codes/E0782.md"),
|
||||
E0783: include_str!("./error_codes/E0783.md"),
|
||||
;
|
||||
// E0006, // merged with E0005
|
||||
// E0008, // cannot bind by-move into a pattern guard
|
||||
|
26
compiler/rustc_error_codes/src/error_codes/E0782.md
Normal file
26
compiler/rustc_error_codes/src/error_codes/E0782.md
Normal file
@ -0,0 +1,26 @@
|
||||
Trait objects must include the `dyn` keyword.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```edition2021,compile_fail,E0782
|
||||
trait Foo {}
|
||||
fn test(arg: Box<Foo>) {} // error!
|
||||
```
|
||||
|
||||
Trait objects are a way to call methods on types that are not known until
|
||||
runtime but conform to some trait.
|
||||
|
||||
Trait objects should be formed with `Box<dyn Foo>`, but in the code above
|
||||
`dyn` is left off.
|
||||
|
||||
This makes it harder to see that `arg` is a trait object and not a
|
||||
simply a heap allocated type called `Foo`.
|
||||
|
||||
To fix this issue, add `dyn` before the trait name.
|
||||
|
||||
```edition2021
|
||||
trait Foo {}
|
||||
fn test(arg: Box<dyn Foo>) {} // ok!
|
||||
```
|
||||
|
||||
This used to be allowed before edition 2021, but is now an error.
|
22
compiler/rustc_error_codes/src/error_codes/E0783.md
Normal file
22
compiler/rustc_error_codes/src/error_codes/E0783.md
Normal file
@ -0,0 +1,22 @@
|
||||
The range pattern `...` is no longer allowed.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```edition2021,compile_fail,E0783
|
||||
match 2u8 {
|
||||
0...9 => println!("Got a number less than 10"), // error!
|
||||
_ => println!("Got a number 10 or more"),
|
||||
}
|
||||
```
|
||||
|
||||
Older Rust code using previous editions allowed `...` to stand for exclusive
|
||||
ranges which are now signified using `..=`.
|
||||
|
||||
To make this code compile replace the `...` with `..=`.
|
||||
|
||||
```edition2021
|
||||
match 2u8 {
|
||||
0..=9 => println!("Got a number less than 10"), // ok!
|
||||
_ => println!("Got a number 10 or more"),
|
||||
}
|
||||
```
|
@ -1660,7 +1660,11 @@ declare_lint! {
|
||||
/// [`..` range expression]: https://doc.rust-lang.org/reference/expressions/range-expr.html
|
||||
pub ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
|
||||
Warn,
|
||||
"`...` range patterns are deprecated"
|
||||
"`...` range patterns are deprecated",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
|
||||
edition: Some(Edition::Edition2021),
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -1704,32 +1708,57 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
||||
let suggestion = "use `..=` for an inclusive range";
|
||||
if parenthesise {
|
||||
self.node_id = Some(pat.id);
|
||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, |lint| {
|
||||
let end = expr_to_string(&end);
|
||||
let replace = match start {
|
||||
Some(start) => format!("&({}..={})", expr_to_string(&start), end),
|
||||
None => format!("&(..={})", end),
|
||||
};
|
||||
lint.build(msg)
|
||||
.span_suggestion(
|
||||
pat.span,
|
||||
suggestion,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
});
|
||||
let end = expr_to_string(&end);
|
||||
let replace = match start {
|
||||
Some(start) => format!("&({}..={})", expr_to_string(&start), end),
|
||||
None => format!("&(..={})", end),
|
||||
};
|
||||
if join.edition() >= Edition::Edition2021 {
|
||||
let mut err =
|
||||
rustc_errors::struct_span_err!(cx.sess, pat.span, E0783, "{}", msg,);
|
||||
err.span_suggestion(
|
||||
pat.span,
|
||||
suggestion,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
} else {
|
||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, |lint| {
|
||||
lint.build(msg)
|
||||
.span_suggestion(
|
||||
pat.span,
|
||||
suggestion,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, |lint| {
|
||||
lint.build(msg)
|
||||
.span_suggestion_short(
|
||||
join,
|
||||
suggestion,
|
||||
"..=".to_owned(),
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
});
|
||||
let replace = "..=".to_owned();
|
||||
if join.edition() >= Edition::Edition2021 {
|
||||
let mut err =
|
||||
rustc_errors::struct_span_err!(cx.sess, pat.span, E0783, "{}", msg,);
|
||||
err.span_suggestion_short(
|
||||
join,
|
||||
suggestion,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
} else {
|
||||
cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, |lint| {
|
||||
lint.build(msg)
|
||||
.span_suggestion_short(
|
||||
join,
|
||||
suggestion,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1618,7 +1618,11 @@ declare_lint! {
|
||||
/// [`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
||||
pub BARE_TRAIT_OBJECTS,
|
||||
Warn,
|
||||
"suggest using `dyn Trait` for trait objects"
|
||||
"suggest using `dyn Trait` for trait objects",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reference: "issue #80165 <https://github.com/rust-lang/rust/issues/80165>",
|
||||
edition: Some(Edition::Edition2021),
|
||||
};
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
|
@ -272,11 +272,13 @@ pub fn struct_lint_level<'s, 'd>(
|
||||
// emit shouldn't be automatically fixed by rustfix.
|
||||
err.allow_suggestions(false);
|
||||
|
||||
// If this is a future incompatible lint it'll become a hard error, so
|
||||
// we have to emit *something*. Also, if this lint occurs in the
|
||||
// expansion of a macro from an external crate, allow individual lints
|
||||
// to opt-out from being reported.
|
||||
if future_incompatible.is_none() && !lint.report_in_external_macro {
|
||||
// If this is a future incompatible that is not an edition fixing lint
|
||||
// it'll become a hard error, so we have to emit *something*. Also,
|
||||
// if this lint occurs in the expansion of a macro from an external crate,
|
||||
// allow individual lints to opt-out from being reported.
|
||||
let not_future_incompatible =
|
||||
future_incompatible.map(|f| f.edition.is_some()).unwrap_or(true);
|
||||
if not_future_incompatible && !lint.report_in_external_macro {
|
||||
err.cancel();
|
||||
// Don't continue further, since we don't want to have
|
||||
// `diag_span_note_once` called for a diagnostic that isn't emitted.
|
||||
|
@ -30,6 +30,7 @@ use rustc_middle::ty::{
|
||||
use rustc_session::lint;
|
||||
use rustc_session::lint::builtin::BARE_TRAIT_OBJECTS;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::source_map::{original_sp, DUMMY_SP};
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
use rustc_span::{self, BytePos, MultiSpan, Span};
|
||||
@ -969,20 +970,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if let TyKind::TraitObject([poly_trait_ref, ..], _, TraitObjectSyntax::None) =
|
||||
self_ty.kind
|
||||
{
|
||||
self.tcx.struct_span_lint_hir(BARE_TRAIT_OBJECTS, hir_id, self_ty.span, |lint| {
|
||||
let mut db = lint
|
||||
.build(&format!("trait objects without an explicit `dyn` are deprecated"));
|
||||
let (sugg, app) = match self.tcx.sess.source_map().span_to_snippet(self_ty.span)
|
||||
{
|
||||
Ok(s) if poly_trait_ref.trait_ref.path.is_global() => {
|
||||
(format!("<dyn ({})>", s), Applicability::MachineApplicable)
|
||||
}
|
||||
Ok(s) => (format!("<dyn {}>", s), Applicability::MachineApplicable),
|
||||
Err(_) => ("<dyn <type>>".to_string(), Applicability::HasPlaceholders),
|
||||
};
|
||||
db.span_suggestion(self_ty.span, "use `dyn`", sugg, app);
|
||||
db.emit()
|
||||
});
|
||||
let msg = "trait objects without an explicit `dyn` are deprecated";
|
||||
let (sugg, app) = match self.tcx.sess.source_map().span_to_snippet(self_ty.span) {
|
||||
Ok(s) if poly_trait_ref.trait_ref.path.is_global() => {
|
||||
(format!("<dyn ({})>", s), Applicability::MachineApplicable)
|
||||
}
|
||||
Ok(s) => (format!("<dyn {}>", s), Applicability::MachineApplicable),
|
||||
Err(_) => ("<dyn <type>>".to_string(), Applicability::HasPlaceholders),
|
||||
};
|
||||
let replace = String::from("use `dyn`");
|
||||
if self.sess().edition() >= Edition::Edition2021 {
|
||||
let mut err = rustc_errors::struct_span_err!(
|
||||
self.sess(),
|
||||
self_ty.span,
|
||||
E0783,
|
||||
"{}",
|
||||
msg,
|
||||
);
|
||||
err.span_suggestion(
|
||||
self_ty.span,
|
||||
&sugg,
|
||||
replace,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
} else {
|
||||
self.tcx.struct_span_lint_hir(
|
||||
BARE_TRAIT_OBJECTS,
|
||||
hir_id,
|
||||
self_ty.span,
|
||||
|lint| {
|
||||
let mut db = lint.build(msg);
|
||||
db.span_suggestion(self_ty.span, &replace, sugg, app);
|
||||
db.emit()
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1709,6 +1709,9 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
|
||||
builder.info(&format!("doc tests for: {}", markdown.display()));
|
||||
let mut cmd = builder.rustdoc_cmd(compiler);
|
||||
builder.add_rust_test_threads(&mut cmd);
|
||||
// allow for unstable options such as new editions
|
||||
cmd.arg("-Z");
|
||||
cmd.arg("unstable-options");
|
||||
cmd.arg("--test");
|
||||
cmd.arg(markdown);
|
||||
cmd.env("RUSTC_BOOTSTRAP", "1");
|
||||
|
@ -13,6 +13,7 @@ fn b() {
|
||||
//~| ERROR expected trait, found constant `BAR`
|
||||
//~| ERROR type provided when a constant was expected
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
}
|
||||
fn c() {
|
||||
foo::<3 + 3>(); //~ ERROR expressions must be enclosed in braces
|
||||
|
@ -10,7 +10,7 @@ LL | foo::<{ BAR + 3 }>();
|
||||
| ^ ^
|
||||
|
||||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:18:11
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:19:11
|
||||
|
|
||||
LL | foo::<3 + 3>();
|
||||
| ^^^^^
|
||||
@ -21,7 +21,7 @@ LL | foo::<{ 3 + 3 }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:21:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:22:15
|
||||
|
|
||||
LL | foo::<BAR - 3>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -32,7 +32,7 @@ LL | foo::<{ BAR - 3 }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:24:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:25:15
|
||||
|
|
||||
LL | foo::<BAR - BAR>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -43,7 +43,7 @@ LL | foo::<{ BAR - BAR }>();
|
||||
| ^ ^
|
||||
|
||||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:27:11
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:28:11
|
||||
|
|
||||
LL | foo::<100 - BAR>();
|
||||
| ^^^^^^^^^
|
||||
@ -54,7 +54,7 @@ LL | foo::<{ 100 - BAR }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:30:19
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:31:19
|
||||
|
|
||||
LL | foo::<bar<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -65,7 +65,7 @@ LL | foo::<{ bar<i32>() }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:33:21
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:34:21
|
||||
|
|
||||
LL | foo::<bar::<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -76,7 +76,7 @@ LL | foo::<{ bar::<i32>() }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:36:21
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:37:21
|
||||
|
|
||||
LL | foo::<bar::<i32>() + BAR>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -87,7 +87,7 @@ LL | foo::<{ bar::<i32>() + BAR }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:39:21
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:40:21
|
||||
|
|
||||
LL | foo::<bar::<i32>() - BAR>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -98,7 +98,7 @@ LL | foo::<{ bar::<i32>() - BAR }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:42:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:43:15
|
||||
|
|
||||
LL | foo::<BAR - bar::<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -109,7 +109,7 @@ LL | foo::<{ BAR - bar::<i32>() }>();
|
||||
| ^ ^
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:45:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:46:15
|
||||
|
|
||||
LL | foo::<BAR - bar::<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -138,6 +138,8 @@ LL | foo::<BAR + BAR>();
|
||||
| ^^^^^^^^^ help: use `dyn`: `dyn BAR + BAR`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:11:11
|
||||
|
16
src/test/ui/dyn-keyword/dyn-2018-edition-lint.rs
Normal file
16
src/test/ui/dyn-keyword/dyn-2018-edition-lint.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// edition:2018
|
||||
#[deny(bare_trait_objects)]
|
||||
|
||||
fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||
//~^ ERROR trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted
|
||||
//~| ERROR trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted
|
||||
let _x: &SomeTrait = todo!();
|
||||
//~^ ERROR trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted
|
||||
}
|
||||
|
||||
trait SomeTrait {}
|
||||
|
||||
fn main() {}
|
34
src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr
Normal file
34
src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr
Normal file
@ -0,0 +1,34 @@
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/dyn-2018-edition-lint.rs:4:17
|
||||
|
|
||||
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/dyn-2018-edition-lint.rs:2:8
|
||||
|
|
||||
LL | #[deny(bare_trait_objects)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/dyn-2018-edition-lint.rs:4:35
|
||||
|
|
||||
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/dyn-2018-edition-lint.rs:9:14
|
||||
|
|
||||
LL | let _x: &SomeTrait = todo!();
|
||||
| ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
12
src/test/ui/dyn-keyword/dyn-2021-edition-error.rs
Normal file
12
src/test/ui/dyn-keyword/dyn-2021-edition-error.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// edition:2021
|
||||
|
||||
fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||
//~^ ERROR trait objects must include the `dyn` keyword
|
||||
//~| ERROR trait objects must include the `dyn` keyword
|
||||
let _x: &SomeTrait = todo!();
|
||||
//~^ ERROR trait objects must include the `dyn` keyword
|
||||
}
|
||||
|
||||
trait SomeTrait {}
|
||||
|
||||
fn main() {}
|
36
src/test/ui/dyn-keyword/dyn-2021-edition-error.stderr
Normal file
36
src/test/ui/dyn-keyword/dyn-2021-edition-error.stderr
Normal file
@ -0,0 +1,36 @@
|
||||
error[E0782]: trait objects must include the `dyn` keyword
|
||||
--> $DIR/dyn-2021-edition-error.rs:6:14
|
||||
|
|
||||
LL | let _x: &SomeTrait = todo!();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: add `dyn` keyword before this trait
|
||||
|
|
||||
LL | let _x: &dyn SomeTrait = todo!();
|
||||
| ^^^
|
||||
|
||||
error[E0782]: trait objects must include the `dyn` keyword
|
||||
--> $DIR/dyn-2021-edition-error.rs:3:17
|
||||
|
|
||||
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: add `dyn` keyword before this trait
|
||||
|
|
||||
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
|
||||
| ^^^
|
||||
|
||||
error[E0782]: trait objects must include the `dyn` keyword
|
||||
--> $DIR/dyn-2021-edition-error.rs:3:35
|
||||
|
|
||||
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: add `dyn` keyword before this trait
|
||||
|
|
||||
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0782`.
|
@ -11,5 +11,6 @@ fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
|
||||
//~^ ERROR: lifetime in trait object type must be followed by `+`
|
||||
//~| ERROR: parenthesized generic arguments cannot be used
|
||||
//~| WARNING: trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARNING: this was previously accepted by the compiler
|
||||
|
||||
fn main() {}
|
||||
|
@ -26,6 +26,8 @@ LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
|
||||
| ^^ help: use `dyn`: `dyn 'a`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
|
||||
--> $DIR/gat-trait-path-parenthesised-args.rs:5:8
|
||||
|
@ -11,8 +11,14 @@ trait Dyn {}
|
||||
impl Assoc for dyn Dyn {}
|
||||
|
||||
fn main() {
|
||||
Dyn::func(); //~ WARN trait objects without an explicit `dyn` are deprecated
|
||||
::Dyn::func(); //~ WARN trait objects without an explicit `dyn` are deprecated
|
||||
Dyn::CONST; //~ WARN trait objects without an explicit `dyn` are deprecated
|
||||
Dyn::func();
|
||||
//~^ WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
::Dyn::func();
|
||||
//~^ WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
Dyn::CONST;
|
||||
//~^ WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
let _: Dyn::Ty; //~ ERROR ambiguous associated type
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0223]: ambiguous associated type
|
||||
--> $DIR/bare-trait-objects-path.rs:17:12
|
||||
--> $DIR/bare-trait-objects-path.rs:23:12
|
||||
|
|
||||
LL | let _: Dyn::Ty;
|
||||
| ^^^^^^^ help: use fully-qualified syntax: `<dyn Dyn as Trait>::Ty`
|
||||
@ -11,18 +11,26 @@ LL | Dyn::func();
|
||||
| ^^^ help: use `dyn`: `<dyn Dyn>`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
warning: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/bare-trait-objects-path.rs:15:5
|
||||
--> $DIR/bare-trait-objects-path.rs:17:5
|
||||
|
|
||||
LL | ::Dyn::func();
|
||||
| ^^^^^ help: use `dyn`: `<dyn (::Dyn)>`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
warning: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/bare-trait-objects-path.rs:16:5
|
||||
--> $DIR/bare-trait-objects-path.rs:20:5
|
||||
|
|
||||
LL | Dyn::CONST;
|
||||
| ^^^ help: use `dyn`: `<dyn Dyn>`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: aborting due to previous error; 3 warnings emitted
|
||||
|
||||
|
@ -8,12 +8,14 @@ fn main() {
|
||||
match despondency {
|
||||
1..=2 => {}
|
||||
//~^ WARN `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match &despondency {
|
||||
&(1..=2) => {}
|
||||
//~^ WARN `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,14 @@ fn main() {
|
||||
match despondency {
|
||||
1...2 => {}
|
||||
//~^ WARN `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match &despondency {
|
||||
&1...2 => {}
|
||||
//~^ WARN `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,17 @@ note: the lint level is defined here
|
||||
|
|
||||
LL | #![warn(ellipsis_inclusive_range_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
warning: `...` range patterns are deprecated
|
||||
--> $DIR/inclusive-range-pattern-syntax.rs:15:9
|
||||
--> $DIR/inclusive-range-pattern-syntax.rs:16:9
|
||||
|
|
||||
LL | &1...2 => {}
|
||||
| ^^^^^^ help: use `..=` for an inclusive range: `&(1..=2)`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
@ -4,3 +4,4 @@ type X<'a> = (?'a) +;
|
||||
//~^ ERROR `?` may only modify trait bounds, not lifetime bounds
|
||||
//~| ERROR at least one trait is required for an object type
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
|
@ -11,6 +11,8 @@ LL | type X<'a> = (?'a) +;
|
||||
| ^^^^^^^ help: use `dyn`: `dyn (?'a) +`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error[E0224]: at least one trait is required for an object type
|
||||
--> $DIR/issue-68890-2.rs:3:14
|
||||
|
@ -14,8 +14,10 @@ mac!('a);
|
||||
fn y<'a>(y: &mut 'a + Send) {
|
||||
//~^ ERROR expected a path on the left-hand side of `+`, not `&mut 'a`
|
||||
//~| WARNING trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
//~| ERROR at least one trait is required for an object type
|
||||
let z = y as &mut 'a + Send;
|
||||
//~^ ERROR expected value, found trait `Send`
|
||||
//~| WARNING trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ LL | mac!('a);
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0423]: expected value, found trait `Send`
|
||||
--> $DIR/issue-73568-lifetime-after-mut.rs:18:28
|
||||
--> $DIR/issue-73568-lifetime-after-mut.rs:19:28
|
||||
|
|
||||
LL | let z = y as &mut 'a + Send;
|
||||
| ^^^^ not a value
|
||||
@ -34,12 +34,17 @@ LL | fn y<'a>(y: &mut 'a + Send) {
|
||||
| ^^ help: use `dyn`: `dyn 'a`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
warning: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/issue-73568-lifetime-after-mut.rs:18:23
|
||||
--> $DIR/issue-73568-lifetime-after-mut.rs:19:23
|
||||
|
|
||||
LL | let z = y as &mut 'a + Send;
|
||||
| ^^ help: use `dyn`: `dyn 'a`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error[E0224]: at least one trait is required for an object type
|
||||
--> $DIR/issue-73568-lifetime-after-mut.rs:14:18
|
||||
|
@ -12,4 +12,5 @@ fn main() {
|
||||
//~^ ERROR lifetime in trait object type must be followed by `+`
|
||||
//~| ERROR at least one trait is required for an object type
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ LL | m!('static);
|
||||
| ^^^^^^^ help: use `dyn`: `dyn 'static`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error[E0224]: at least one trait is required for an object type
|
||||
--> $DIR/trait-object-macro-matcher.rs:11:8
|
||||
|
@ -39,20 +39,32 @@ fn inclusive_from_to() {
|
||||
}
|
||||
|
||||
fn inclusive2_from_to() {
|
||||
if let 0...3 = 0 {} //~ ERROR `...` range patterns are deprecated
|
||||
if let 0...Y = 0 {} //~ ERROR `...` range patterns are deprecated
|
||||
if let X...3 = 0 {} //~ ERROR `...` range patterns are deprecated
|
||||
if let X...Y = 0 {} //~ ERROR `...` range patterns are deprecated
|
||||
if let 0...3 = 0 {}
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
if let 0...Y = 0 {}
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
if let X...3 = 0 {}
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
if let X...Y = 0 {}
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
if let true...Y = 0 {} //~ ERROR only `char` and numeric types
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
if let X...true = 0 {} //~ ERROR only `char` and numeric types
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
if let .0...Y = 0 {} //~ ERROR mismatched types
|
||||
//~^ ERROR float literals must have an integer part
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
//~| ERROR `...` range patterns are deprecated
|
||||
if let X... .0 = 0 {} //~ ERROR mismatched types
|
||||
//~^ ERROR float literals must have an integer part
|
||||
//~| ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
}
|
||||
|
||||
fn exclusive_from() {
|
||||
@ -125,6 +137,7 @@ fn with_macro_expr_var() {
|
||||
let $e1..$e2;
|
||||
let $e1...$e2;
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
let $e1..=$e2;
|
||||
}
|
||||
}
|
||||
|
@ -23,25 +23,25 @@ LL | if let X..=.0 = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:50:12
|
||||
--> $DIR/recover-range-pats.rs:60:12
|
||||
|
|
||||
LL | if let .0...Y = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:53:17
|
||||
--> $DIR/recover-range-pats.rs:64:17
|
||||
|
|
||||
LL | if let X... .0 = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:63:12
|
||||
--> $DIR/recover-range-pats.rs:75:12
|
||||
|
|
||||
LL | if let .0.. = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:69:13
|
||||
--> $DIR/recover-range-pats.rs:81:13
|
||||
|
|
||||
LL | if let 0..= = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -49,7 +49,7 @@ LL | if let 0..= = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:70:13
|
||||
--> $DIR/recover-range-pats.rs:82:13
|
||||
|
|
||||
LL | if let X..= = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -57,7 +57,7 @@ LL | if let X..= = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:71:16
|
||||
--> $DIR/recover-range-pats.rs:83:16
|
||||
|
|
||||
LL | if let true..= = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -65,13 +65,13 @@ LL | if let true..= = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:73:12
|
||||
--> $DIR/recover-range-pats.rs:85:12
|
||||
|
|
||||
LL | if let .0..= = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:73:14
|
||||
--> $DIR/recover-range-pats.rs:85:14
|
||||
|
|
||||
LL | if let .0..= = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -79,7 +79,7 @@ LL | if let .0..= = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:79:13
|
||||
--> $DIR/recover-range-pats.rs:91:13
|
||||
|
|
||||
LL | if let 0... = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -87,7 +87,7 @@ LL | if let 0... = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:80:13
|
||||
--> $DIR/recover-range-pats.rs:92:13
|
||||
|
|
||||
LL | if let X... = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -95,7 +95,7 @@ LL | if let X... = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:81:16
|
||||
--> $DIR/recover-range-pats.rs:93:16
|
||||
|
|
||||
LL | if let true... = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -103,13 +103,13 @@ LL | if let true... = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:83:12
|
||||
--> $DIR/recover-range-pats.rs:95:12
|
||||
|
|
||||
LL | if let .0... = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:83:14
|
||||
--> $DIR/recover-range-pats.rs:95:14
|
||||
|
|
||||
LL | if let .0... = 0 {}
|
||||
| ^^^ help: use `..` instead
|
||||
@ -117,49 +117,49 @@ LL | if let .0... = 0 {}
|
||||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:93:15
|
||||
--> $DIR/recover-range-pats.rs:105:15
|
||||
|
|
||||
LL | if let .. .0 = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:103:15
|
||||
--> $DIR/recover-range-pats.rs:115:15
|
||||
|
|
||||
LL | if let ..=.0 = 0 {}
|
||||
| ^^ help: must have an integer part: `0.0`
|
||||
|
||||
error: range-to patterns with `...` are not allowed
|
||||
--> $DIR/recover-range-pats.rs:109:12
|
||||
--> $DIR/recover-range-pats.rs:121:12
|
||||
|
|
||||
LL | if let ...3 = 0 {}
|
||||
| ^^^ help: use `..=` instead
|
||||
|
||||
error: range-to patterns with `...` are not allowed
|
||||
--> $DIR/recover-range-pats.rs:111:12
|
||||
--> $DIR/recover-range-pats.rs:123:12
|
||||
|
|
||||
LL | if let ...Y = 0 {}
|
||||
| ^^^ help: use `..=` instead
|
||||
|
||||
error: range-to patterns with `...` are not allowed
|
||||
--> $DIR/recover-range-pats.rs:113:12
|
||||
--> $DIR/recover-range-pats.rs:125:12
|
||||
|
|
||||
LL | if let ...true = 0 {}
|
||||
| ^^^ help: use `..=` instead
|
||||
|
||||
error: float literals must have an integer part
|
||||
--> $DIR/recover-range-pats.rs:116:15
|
||||
--> $DIR/recover-range-pats.rs:128:15
|
||||
|
|
||||
LL | if let ....3 = 0 {}
|
||||
| ^^ help: must have an integer part: `0.3`
|
||||
|
||||
error: range-to patterns with `...` are not allowed
|
||||
--> $DIR/recover-range-pats.rs:116:12
|
||||
--> $DIR/recover-range-pats.rs:128:12
|
||||
|
|
||||
LL | if let ....3 = 0 {}
|
||||
| ^^^ help: use `..=` instead
|
||||
|
||||
error: range-to patterns with `...` are not allowed
|
||||
--> $DIR/recover-range-pats.rs:137:17
|
||||
--> $DIR/recover-range-pats.rs:150:17
|
||||
|
|
||||
LL | let ...$e;
|
||||
| ^^^ help: use `..=` instead
|
||||
@ -170,7 +170,7 @@ LL | mac!(0);
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:141:19
|
||||
--> $DIR/recover-range-pats.rs:154:19
|
||||
|
|
||||
LL | let $e...;
|
||||
| ^^^ help: use `..` instead
|
||||
@ -182,7 +182,7 @@ LL | mac!(0);
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0586]: inclusive range with no end
|
||||
--> $DIR/recover-range-pats.rs:142:19
|
||||
--> $DIR/recover-range-pats.rs:155:19
|
||||
|
|
||||
LL | let $e..=;
|
||||
| ^^^ help: use `..` instead
|
||||
@ -204,51 +204,74 @@ note: the lint level is defined here
|
||||
|
|
||||
LL | #![deny(ellipsis_inclusive_range_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:43:13
|
||||
|
|
||||
LL | if let 0...Y = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:44:13
|
||||
|
|
||||
LL | if let X...3 = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:45:13
|
||||
|
|
||||
LL | if let X...Y = 0 {}
|
||||
LL | if let 0...Y = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:46:16
|
||||
|
|
||||
LL | if let true...Y = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:48:13
|
||||
|
|
||||
LL | if let X...true = 0 {}
|
||||
LL | if let X...3 = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:50:14
|
||||
--> $DIR/recover-range-pats.rs:51:13
|
||||
|
|
||||
LL | if let X...Y = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:54:16
|
||||
|
|
||||
LL | if let true...Y = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:57:13
|
||||
|
|
||||
LL | if let X...true = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:60:14
|
||||
|
|
||||
LL | if let .0...Y = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:53:13
|
||||
--> $DIR/recover-range-pats.rs:64:13
|
||||
|
|
||||
LL | if let X... .0 = 0 {}
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: `...` range patterns are deprecated
|
||||
--> $DIR/recover-range-pats.rs:126:20
|
||||
--> $DIR/recover-range-pats.rs:138:20
|
||||
|
|
||||
LL | let $e1...$e2;
|
||||
| ^^^ help: use `..=` for an inclusive range
|
||||
@ -256,6 +279,8 @@ LL | let $e1...$e2;
|
||||
LL | mac2!(0, 1);
|
||||
| ------------ in this macro invocation
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
@ -325,7 +350,7 @@ LL | if let X..=.0 = 0 {}
|
||||
| this is of type `u8`
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:46:12
|
||||
--> $DIR/recover-range-pats.rs:54:12
|
||||
|
|
||||
LL | if let true...Y = 0 {}
|
||||
| ^^^^ - this is of type `u8`
|
||||
@ -333,7 +358,7 @@ LL | if let true...Y = 0 {}
|
||||
| this is of type `bool` but it should be `char` or numeric
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:48:16
|
||||
--> $DIR/recover-range-pats.rs:57:16
|
||||
|
|
||||
LL | if let X...true = 0 {}
|
||||
| - ^^^^ this is of type `bool` but it should be `char` or numeric
|
||||
@ -341,7 +366,7 @@ LL | if let X...true = 0 {}
|
||||
| this is of type `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:50:12
|
||||
--> $DIR/recover-range-pats.rs:60:12
|
||||
|
|
||||
LL | if let .0...Y = 0 {}
|
||||
| ^^ - this is of type `u8`
|
||||
@ -349,7 +374,7 @@ LL | if let .0...Y = 0 {}
|
||||
| expected integer, found floating-point number
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:53:17
|
||||
--> $DIR/recover-range-pats.rs:64:17
|
||||
|
|
||||
LL | if let X... .0 = 0 {}
|
||||
| - ^^ - this expression has type `u8`
|
||||
@ -358,73 +383,73 @@ LL | if let X... .0 = 0 {}
|
||||
| this is of type `u8`
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:61:12
|
||||
--> $DIR/recover-range-pats.rs:73:12
|
||||
|
|
||||
LL | if let true.. = 0 {}
|
||||
| ^^^^ this is of type `bool` but it should be `char` or numeric
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:63:12
|
||||
--> $DIR/recover-range-pats.rs:75:12
|
||||
|
|
||||
LL | if let .0.. = 0 {}
|
||||
| ^^ expected integer, found floating-point number
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:71:12
|
||||
--> $DIR/recover-range-pats.rs:83:12
|
||||
|
|
||||
LL | if let true..= = 0 {}
|
||||
| ^^^^ this is of type `bool` but it should be `char` or numeric
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:73:12
|
||||
--> $DIR/recover-range-pats.rs:85:12
|
||||
|
|
||||
LL | if let .0..= = 0 {}
|
||||
| ^^ expected integer, found floating-point number
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:81:12
|
||||
--> $DIR/recover-range-pats.rs:93:12
|
||||
|
|
||||
LL | if let true... = 0 {}
|
||||
| ^^^^ this is of type `bool` but it should be `char` or numeric
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:83:12
|
||||
--> $DIR/recover-range-pats.rs:95:12
|
||||
|
|
||||
LL | if let .0... = 0 {}
|
||||
| ^^ expected integer, found floating-point number
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:91:14
|
||||
--> $DIR/recover-range-pats.rs:103:14
|
||||
|
|
||||
LL | if let ..true = 0 {}
|
||||
| ^^^^ this is of type `bool` but it should be `char` or numeric
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:93:15
|
||||
--> $DIR/recover-range-pats.rs:105:15
|
||||
|
|
||||
LL | if let .. .0 = 0 {}
|
||||
| ^^ expected integer, found floating-point number
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:101:15
|
||||
--> $DIR/recover-range-pats.rs:113:15
|
||||
|
|
||||
LL | if let ..=true = 0 {}
|
||||
| ^^^^ this is of type `bool` but it should be `char` or numeric
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:103:15
|
||||
--> $DIR/recover-range-pats.rs:115:15
|
||||
|
|
||||
LL | if let ..=.0 = 0 {}
|
||||
| ^^ expected integer, found floating-point number
|
||||
|
||||
error[E0029]: only `char` and numeric types are allowed in range patterns
|
||||
--> $DIR/recover-range-pats.rs:113:15
|
||||
--> $DIR/recover-range-pats.rs:125:15
|
||||
|
|
||||
LL | if let ...true = 0 {}
|
||||
| ^^^^ this is of type `bool` but it should be `char` or numeric
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recover-range-pats.rs:116:15
|
||||
--> $DIR/recover-range-pats.rs:128:15
|
||||
|
|
||||
LL | if let ....3 = 0 {}
|
||||
| ^^ expected integer, found floating-point number
|
||||
|
@ -9,12 +9,15 @@ fn main() {
|
||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||
//~| ERROR only auto traits can be used as additional traits
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Obj)>;
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>;
|
||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||
//~| ERROR only auto traits can be used as additional traits
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
let _: Box<(for<'a> Trait<'a>) + (Obj) + (?Sized)>;
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>;
|
||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||
//~| ERROR only auto traits can be used as additional traits
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
}
|
||||
|
@ -5,16 +5,16 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `?Trait` is not permitted in trait object types
|
||||
--> $DIR/trait-object-trait-parens.rs:12:17
|
||||
--> $DIR/trait-object-trait-parens.rs:13:16
|
||||
|
|
||||
LL | let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Obj)>;
|
||||
| ^^^^^^
|
||||
LL | let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>;
|
||||
| ^^^^^^
|
||||
|
||||
error: `?Trait` is not permitted in trait object types
|
||||
--> $DIR/trait-object-trait-parens.rs:16:46
|
||||
--> $DIR/trait-object-trait-parens.rs:18:44
|
||||
|
|
||||
LL | let _: Box<(for<'a> Trait<'a>) + (Obj) + (?Sized)>;
|
||||
| ^^^^^^^^
|
||||
LL | let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>;
|
||||
| ^^^^^^^^
|
||||
|
||||
warning: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/trait-object-trait-parens.rs:8:16
|
||||
@ -23,18 +23,26 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
warning: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/trait-object-trait-parens.rs:12:16
|
||||
--> $DIR/trait-object-trait-parens.rs:13:16
|
||||
|
|
||||
LL | let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Obj)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (?Sized) + (for<'a> Trait<'a>) + (Obj)`
|
||||
LL | let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn ?Sized + (for<'a> Trait<'a>) + (Obj)`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
warning: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/trait-object-trait-parens.rs:16:16
|
||||
--> $DIR/trait-object-trait-parens.rs:18:16
|
||||
|
|
||||
LL | let _: Box<(for<'a> Trait<'a>) + (Obj) + (?Sized)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (for<'a> Trait<'a>) + (Obj) + (?Sized)`
|
||||
LL | let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> Trait<'a> + (Obj) + (?Sized)`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error[E0225]: only auto traits can be used as additional traits in a trait object
|
||||
--> $DIR/trait-object-trait-parens.rs:8:35
|
||||
@ -48,23 +56,23 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>;
|
||||
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
|
||||
|
||||
error[E0225]: only auto traits can be used as additional traits in a trait object
|
||||
--> $DIR/trait-object-trait-parens.rs:12:49
|
||||
--> $DIR/trait-object-trait-parens.rs:13:47
|
||||
|
|
||||
LL | let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Obj)>;
|
||||
| ------------------- ^^^^^ additional non-auto trait
|
||||
| |
|
||||
| first non-auto trait
|
||||
LL | let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>;
|
||||
| ------------------- ^^^^^ additional non-auto trait
|
||||
| |
|
||||
| first non-auto trait
|
||||
|
|
||||
= help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: for<'a> Trait<'a> + Obj {}`
|
||||
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
|
||||
|
||||
error[E0225]: only auto traits can be used as additional traits in a trait object
|
||||
--> $DIR/trait-object-trait-parens.rs:16:38
|
||||
--> $DIR/trait-object-trait-parens.rs:18:36
|
||||
|
|
||||
LL | let _: Box<(for<'a> Trait<'a>) + (Obj) + (?Sized)>;
|
||||
| ----------------- ^^^^^ additional non-auto trait
|
||||
| |
|
||||
| first non-auto trait
|
||||
LL | let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>;
|
||||
| ----------------- ^^^^^ additional non-auto trait
|
||||
| |
|
||||
| first non-auto trait
|
||||
|
|
||||
= help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: for<'a> Trait<'a> + Obj {}`
|
||||
= note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
|
||||
|
14
src/test/ui/range/exclusive-range-patterns-2021.rs
Normal file
14
src/test/ui/range/exclusive-range-patterns-2021.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// edition:2021
|
||||
|
||||
fn main() {
|
||||
let n = 2;
|
||||
match n {
|
||||
0...3 => {}
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
4...10 => {}
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
(11...100) => {}
|
||||
//~^ ERROR `...` range patterns are deprecated
|
||||
_ => {}
|
||||
}
|
||||
}
|
27
src/test/ui/range/exclusive-range-patterns-2021.stderr
Normal file
27
src/test/ui/range/exclusive-range-patterns-2021.stderr
Normal file
@ -0,0 +1,27 @@
|
||||
error[E0783]: `...` range patterns are deprecated
|
||||
--> $DIR/exclusive-range-patterns-2021.rs:6:9
|
||||
|
|
||||
LL | 0...3 => {}
|
||||
| ^---^
|
||||
| |
|
||||
| help: use `..=` for an inclusive range
|
||||
|
||||
error[E0783]: `...` range patterns are deprecated
|
||||
--> $DIR/exclusive-range-patterns-2021.rs:8:9
|
||||
|
|
||||
LL | 4...10 => {}
|
||||
| ^---^^
|
||||
| |
|
||||
| help: use `..=` for an inclusive range
|
||||
|
||||
error[E0783]: `...` range patterns are deprecated
|
||||
--> $DIR/exclusive-range-patterns-2021.rs:10:10
|
||||
|
|
||||
LL | (11...100) => {}
|
||||
| ^^---^^^
|
||||
| |
|
||||
| help: use `..=` for an inclusive range
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0783`.
|
@ -10,10 +10,11 @@ pub fn main() {
|
||||
match &12 {
|
||||
&(0..=9) => {}
|
||||
//~^ WARN `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
//~| HELP use `..=` for an inclusive range
|
||||
&(10 ..=15) => {}
|
||||
//~^ ERROR the range pattern here has ambiguous interpretation
|
||||
//~^^ HELP add parentheses to clarify the precedence
|
||||
//~| HELP add parentheses to clarify the precedence
|
||||
&(16..=20) => {}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -10,10 +10,11 @@ pub fn main() {
|
||||
match &12 {
|
||||
&0...9 => {}
|
||||
//~^ WARN `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
//~| HELP use `..=` for an inclusive range
|
||||
&10..=15 => {}
|
||||
//~^ ERROR the range pattern here has ambiguous interpretation
|
||||
//~^^ HELP add parentheses to clarify the precedence
|
||||
//~| HELP add parentheses to clarify the precedence
|
||||
&(16..=20) => {}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: the range pattern here has ambiguous interpretation
|
||||
--> $DIR/range-inclusive-pattern-precedence.rs:14:10
|
||||
--> $DIR/range-inclusive-pattern-precedence.rs:15:10
|
||||
|
|
||||
LL | &10..=15 => {}
|
||||
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10 ..=15)`
|
||||
@ -15,6 +15,8 @@ note: the lint level is defined here
|
||||
|
|
||||
LL | #![warn(ellipsis_inclusive_range_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
|
@ -9,6 +9,7 @@ fn main() {
|
||||
// FIXME: can we add suggestions like `&(0..=9)`?
|
||||
box 0...9 => {}
|
||||
//~^ WARN `...` range patterns are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
//~| HELP use `..=` for an inclusive range
|
||||
box 10..=15 => {}
|
||||
//~^ ERROR the range pattern here has ambiguous interpretation
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: the range pattern here has ambiguous interpretation
|
||||
--> $DIR/range-inclusive-pattern-precedence2.rs:13:13
|
||||
--> $DIR/range-inclusive-pattern-precedence2.rs:14:13
|
||||
|
|
||||
LL | box 10..=15 => {}
|
||||
| ^^^^^^^ help: add parentheses to clarify the precedence: `(10 ..=15)`
|
||||
@ -15,6 +15,8 @@ note: the lint level is defined here
|
||||
|
|
||||
LL | #![warn(ellipsis_inclusive_range_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
|
@ -14,12 +14,8 @@ pub struct Foo;
|
||||
mod test {
|
||||
use crate::foo::foo;
|
||||
|
||||
#[foo] //~ WARN: absolute paths must start with
|
||||
//~| WARN: previously accepted
|
||||
//~| WARN: absolute paths
|
||||
//~| WARN: previously accepted
|
||||
fn main() {
|
||||
}
|
||||
#[foo]
|
||||
fn main() {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -14,12 +14,8 @@ pub struct Foo;
|
||||
mod test {
|
||||
use crate::foo::foo;
|
||||
|
||||
#[foo] //~ WARN: absolute paths must start with
|
||||
//~| WARN: previously accepted
|
||||
//~| WARN: absolute paths
|
||||
//~| WARN: previously accepted
|
||||
fn main() {
|
||||
}
|
||||
#[foo]
|
||||
fn main() {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,28 +0,0 @@
|
||||
warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
|
||||
--> $DIR/suggestions-not-always-applicable.rs:17:5
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/suggestions-not-always-applicable.rs:8:9
|
||||
|
|
||||
LL | #![warn(rust_2018_compatibility)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: `#[warn(absolute_paths_not_starting_with_crate)]` implied by `#[warn(rust_2018_compatibility)]`
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
|
||||
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
|
||||
= note: this warning originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
|
||||
--> $DIR/suggestions-not-always-applicable.rs:17:5
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
|
||||
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
|
||||
= note: this warning originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
@ -11,15 +11,17 @@ extern crate issue_61963_1;
|
||||
// generate code which would trigger the lint.
|
||||
|
||||
pub struct Baz;
|
||||
pub trait Bar { }
|
||||
pub trait Bar {}
|
||||
pub struct Qux<T>(T);
|
||||
|
||||
#[dom_struct]
|
||||
pub struct Foo {
|
||||
//~^ ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
qux: Qux<Qux<Baz>>,
|
||||
bar: Box<Bar>,
|
||||
//~^ ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/issue-61963.rs:21:14
|
||||
--> $DIR/issue-61963.rs:22:14
|
||||
|
|
||||
LL | bar: Box<Bar>,
|
||||
| ^^^ help: use `dyn`: `dyn Bar`
|
||||
@ -9,12 +9,17 @@ note: the lint level is defined here
|
||||
|
|
||||
LL | #![deny(bare_trait_objects)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/issue-61963.rs:18:1
|
||||
|
|
||||
LL | pub struct Foo {
|
||||
| ^^^ help: use `dyn`: `dyn pub`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
trait Foo {
|
||||
fn dummy(&self) { }
|
||||
fn dummy(&self) {}
|
||||
}
|
||||
|
||||
// This should emit the less confusing error, not the more confusing one.
|
||||
@ -7,6 +7,7 @@ trait Foo {
|
||||
fn foo(_x: Foo + Send) {
|
||||
//~^ ERROR the size for values of type
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this was previously accepted by the compiler
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
fn main() {}
|
||||
|
@ -5,6 +5,8 @@ LL | fn foo(_x: Foo + Send) {
|
||||
| ^^^^^^^^^^ help: use `dyn`: `dyn Foo + Send`
|
||||
|
|
||||
= note: `#[warn(bare_trait_objects)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time
|
||||
--> $DIR/not-on-bare-trait.rs:7:8
|
||||
|
@ -5,18 +5,26 @@ LL | for<'a> Dst<A + 'a>: Sized,
|
||||
| ^^^^^^ help: use `dyn`: `dyn A + 'a`
|
||||
|
|
||||
= note: `-D bare-trait-objects` implied by `-D warnings`
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/ice-3969.rs:27:16
|
||||
|
|
||||
LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
|
||||
| ^ help: use `dyn`: `dyn A`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/ice-3969.rs:27:57
|
||||
|
|
||||
LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
|
||||
| ^ help: use `dyn`: `dyn A`
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
|
||||
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
@ -13,6 +13,7 @@ static GROUP_DESCRIPTIONS: &[(&str, &str)] = &[
|
||||
("nonstandard-style", "Violation of standard naming conventions"),
|
||||
("future-incompatible", "Lints that detect code that has future-compatibility problems"),
|
||||
("rust-2018-compatibility", "Lints used to transition code from the 2015 edition to 2018"),
|
||||
("rust-2021-compatibility", "Lints used to transition code from the 2018 edition to 2021"),
|
||||
];
|
||||
|
||||
type LintGroups = BTreeMap<String, BTreeSet<String>>;
|
||||
|
Loading…
Reference in New Issue
Block a user