Skip to content

Stabilize feature(more_qualified_paths) #141922

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
"`for<...>` binders for closures are experimental",
"consider removing `for<...>`"
);
gate_all!(more_qualified_paths, "usage of qualified paths in this context is experimental");
// yield can be enabled either by `coroutines` or `gen_blocks`
if let Some(spans) = spans.get(&sym::yield_expr) {
for span in spans {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ declare_features! (
(accepted, min_const_unsafe_fn, "1.33.0", Some(55607)),
/// Allows exhaustive pattern matching on uninhabited types when matched by value.
(accepted, min_exhaustive_patterns, "1.82.0", Some(119612)),
/// Allows qualified paths in struct expressions, struct patterns and tuple struct patterns.
(accepted, more_qualified_paths, "CURRENT_RUSTC_VERSION", Some(86935)),
/// Allows using `Self` and associated types in struct expressions and patterns.
(accepted, more_struct_aliases, "1.16.0", Some(37544)),
/// Allows using the MOVBE target feature.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,6 @@ declare_features! (
/// standard library until the soundness issues with specialization
/// are fixed.
(unstable, min_specialization, "1.7.0", Some(31844)),
/// Allows qualified paths in struct expressions, struct patterns and tuple struct patterns.
(unstable, more_qualified_paths, "1.54.0", Some(86935)),
/// Allows the `#[must_not_suspend]` attribute.
(unstable, must_not_suspend, "1.57.0", Some(83310)),
/// Allows `mut ref` and `mut ref mut` identifier patterns.
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1649,9 +1649,6 @@ impl<'a> Parser<'a> {
} else if self.check(exp!(OpenBrace))
&& let Some(expr) = self.maybe_parse_struct_expr(&qself, &path)
{
if qself.is_some() {
self.psess.gated_spans.gate(sym::more_qualified_paths, path.span);
}
return expr;
} else {
(path.span, ExprKind::Path(qself, path))
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,10 +1381,6 @@ impl<'a> Parser<'a> {

/// Parse a struct ("record") pattern (e.g. `Foo { ... }` or `Foo::Bar { ... }`).
fn parse_pat_struct(&mut self, qself: Option<P<QSelf>>, path: Path) -> PResult<'a, PatKind> {
if qself.is_some() {
// Feature gate the use of qualified paths in patterns
self.psess.gated_spans.gate(sym::more_qualified_paths, path.span);
}
self.bump();
let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
e.span_label(path.span, "while parsing the fields for this pattern");
Expand All @@ -1411,9 +1407,6 @@ impl<'a> Parser<'a> {
CommaRecoveryMode::EitherTupleOrPipe,
)
})?;
if qself.is_some() {
self.psess.gated_spans.gate(sym::more_qualified_paths, path.span);
}
Ok(PatKind::TupleStruct(qself, path, fields))
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ check-pass

#![feature(more_qualified_paths)]

enum E { V() }

fn main() {
Expand Down
25 changes: 12 additions & 13 deletions tests/ui/associated-types/associated-type-struct-construction.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// Make sure that users can construct structs through associated types
// in both expressions and patterns
// Check that fully qualified syntax can be used in struct expressions in patterns.
// In other words, check that structs can constructed and destructed via an associated type.
//
//@ run-pass

#![feature(more_qualified_paths)]

//@ check-pass
fn main() {
let <Foo as A>::Assoc { br } = <Foo as A>::Assoc { br: 2 };
assert!(br == 2);
let <Type as Trait>::Assoc { field } = <Type as Trait>::Assoc { field: 2 };
assert_eq!(field, 2);
}

struct StructStruct {
br: i8,
struct Struct {
field: i8,
}

struct Foo;
struct Type;

trait A {
trait Trait {
type Assoc;
}

impl A for Foo {
type Assoc = StructStruct;
impl Trait for Type {
type Assoc = Struct;
}
2 changes: 0 additions & 2 deletions tests/ui/associated-types/tuple-struct-expr-pat.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
//
//@ run-rustfix

#![feature(more_qualified_paths)]

fn main() {
let <T<0> as Trait>::Assoc {} = <T<0> as Trait>::Assoc {};
//~^ error: expected method or associated constant, found associated type
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/associated-types/tuple-struct-expr-pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
//
//@ run-rustfix

#![feature(more_qualified_paths)]

fn main() {
let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc();
//~^ error: expected method or associated constant, found associated type
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/associated-types/tuple-struct-expr-pat.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:10:36
--> $DIR/tuple-struct-expr-pat.rs:8:36
|
LL | let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc();
| ^^^^^^^^^^^^^^^^^^^^^^-- help: use struct expression instead: `{}`
|
= note: can't use a type alias as a constructor

error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:10:9
--> $DIR/tuple-struct-expr-pat.rs:8:9
|
LL | let <T<0> as Trait>::Assoc() = <T<0> as Trait>::Assoc();
| ^^^^^^^^^^^^^^^^^^^^^^-- help: use struct pattern instead: `{}`
|
= note: can't use a type alias as tuple pattern

error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:13:38
--> $DIR/tuple-struct-expr-pat.rs:11:38
|
LL | let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0);
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -28,7 +28,7 @@ LL + let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc { 0: 0 };
|

error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:13:9
--> $DIR/tuple-struct-expr-pat.rs:11:9
|
LL | let <T<1> as Trait>::Assoc(_a) = <T<1> as Trait>::Assoc(0);
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -41,7 +41,7 @@ LL + let <T<1> as Trait>::Assoc { 0: _a } = <T<1> as Trait>::Assoc(0);
|

error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:16:42
--> $DIR/tuple-struct-expr-pat.rs:14:42
|
LL | let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1);
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -54,7 +54,7 @@ LL + let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc { 0: 0, 1:
|

error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:16:9
--> $DIR/tuple-struct-expr-pat.rs:14:9
|
LL | let <T<2> as Trait>::Assoc(_a, _b) = <T<2> as Trait>::Assoc(0, 1);
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -67,7 +67,7 @@ LL + let <T<2> as Trait>::Assoc { 0: _a, 1: _b } = <T<2> as Trait>::Assoc(0,
|

error[E0575]: expected method or associated constant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:19:62
--> $DIR/tuple-struct-expr-pat.rs:17:62
|
LL | let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2);
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -80,7 +80,7 @@ LL + let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait
|

error[E0575]: expected tuple struct or tuple variant, found associated type `Trait::Assoc`
--> $DIR/tuple-struct-expr-pat.rs:19:9
--> $DIR/tuple-struct-expr-pat.rs:17:9
|
LL | let <T<3> as Trait>::Assoc(ref _a, ref mut _b, mut _c) = <T<3> as Trait>::Assoc(0, 1, 2);
| ^^^^^^^^^^^^^^^^^^^^^^
Expand Down
27 changes: 0 additions & 27 deletions tests/ui/feature-gates/feature-gate-more-qualified-paths.rs

This file was deleted.

33 changes: 0 additions & 33 deletions tests/ui/feature-gates/feature-gate-more-qualified-paths.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// issue#121613

#![feature(more_qualified_paths)]

struct S {}

struct Foo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
--> $DIR/incompat-call-after-qualified-path-0.rs:21:6
--> $DIR/incompat-call-after-qualified-path-0.rs:19:6
|
LL | f(|a, b| a.cmp(b));
| ^ - type must be known at this point
Expand All @@ -10,13 +10,13 @@ LL | f(|a: /* Type */, b| a.cmp(b));
| ++++++++++++

error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/incompat-call-after-qualified-path-0.rs:21:3
--> $DIR/incompat-call-after-qualified-path-0.rs:19:3
|
LL | f(|a, b| a.cmp(b));
| ^ --------------- unexpected argument
|
note: function defined here
--> $DIR/incompat-call-after-qualified-path-0.rs:17:4
--> $DIR/incompat-call-after-qualified-path-0.rs:15:4
|
LL | fn f() {}
| ^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// issue#121613

#![feature(more_qualified_paths)]

struct S<T> {
a: T
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
--> $DIR/incompat-call-after-qualified-path-1.rs:25:6
--> $DIR/incompat-call-after-qualified-path-1.rs:23:6
|
LL | f(|a, b| a.cmp(b));
| ^ - type must be known at this point
Expand All @@ -10,13 +10,13 @@ LL | f(|a: /* Type */, b| a.cmp(b));
| ++++++++++++

error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/incompat-call-after-qualified-path-1.rs:25:3
--> $DIR/incompat-call-after-qualified-path-1.rs:23:3
|
LL | f(|a, b| a.cmp(b));
| ^ --------------- unexpected argument
|
note: function defined here
--> $DIR/incompat-call-after-qualified-path-1.rs:19:4
--> $DIR/incompat-call-after-qualified-path-1.rs:17:4
|
LL | fn f() {}
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/macros/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#![feature(explicit_tail_calls)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(more_qualified_paths)]
#![feature(never_patterns)]
#![feature(trait_alias)]
#![feature(try_blocks)]
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/macros/vec-macro-in-pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

fn main() {
match Some(vec![42]) {
Some(vec![43]) => {} //~ ERROR expected a pattern, found a function call
Some(vec![43]) => {}
//~^ ERROR expected a pattern, found a function call
//~| ERROR found associated function
//~| ERROR usage of qualified paths in this context is experimental
_ => {}
}
}
15 changes: 2 additions & 13 deletions tests/ui/macros/vec-macro-in-pattern.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ LL | Some(vec![43]) => {}
= note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: usage of qualified paths in this context is experimental
--> $DIR/vec-macro-in-pattern.rs:7:14
|
LL | Some(vec![43]) => {}
| ^^^^^^^^
|
= note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information
= help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0164]: expected tuple struct or tuple variant, found associated function `<[_]>::into_vec`
--> $DIR/vec-macro-in-pattern.rs:7:14
|
Expand All @@ -27,7 +16,7 @@ LL | Some(vec![43]) => {}
= help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0164, E0532, E0658.
Some errors have detailed explanations: E0164, E0532.
For more information about an error, try `rustc --explain E0164`.
Loading
Loading